Hi Everyone,
I am trying to upload a file using the box API - https://upload.box.com/api/2.0/files/content, however every time I am receiving the below mentioned error:
“XMLHttpRequest cannot load https://upload.box.com/api/2.0/files/content. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 400.”
I have also enabled CORS for my http://localhost:4200 in the box configuration, it is angular project from which I am trying to upload files. Creating folder using folder api is successfull.
Here is my code:
let form = new FormData();
// The content of the file
let fileBody = 'This is a test file';
let uploadUrl = 'https://upload.box.com/api/2.0/files/content';
// The Box OAuth 2 Header. Add your access token.
var headers = {
Authorization: 'Bearer mydevToken',
};
let result = post(uploadUrl, formDataContent, headers);
Thanks in Advance!