I’m always get the error ERR_ABORTED 403 (FORBIDDEN) every time i try to using REST API to upload files !
This is my code
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://192.168.12.91/api/method/run_custom_method', true);
xhr.setRequestHeader('ACCEPT', 'application/json');
xhr.setRequestHeader("Authorization", "Basic " + btoa("xxxxx:yyyyy"));
var b = getBinary(data.pdf_web_location);
var b64 = base64Encode(b);
let from_data = new FormData();
from_data.append('cmd', 'uploadfile')
from_data.append('filename', 'test.pdf');
from_data.append('filedata', b64);
from_data.append('doctype', 'Document');
from_data.append('docname', 'DOC-2019-10-00001');
from_data.append('is_private', '1');
from_data.append('from_form', '1');
xhr.send(from_data);
Any Help!