Hi,
I have a small react web app form which i'm trying to upload file into Box using a custom app.
I am using developer token, white listed the domain http://localhost:3000 in CORS domains.
But I'm still unable to upload the file due to CORS error. However I can create and list the contents of a folder without any error.
Do I need to enable Upload functionality explicitly anywhere on the console?
Here is the code snippet which is doing this. I'm using Axios to post requests
sendRequest(file) {
const attributes = {
"name": "test.png",
"parent": {
"id": "0"
}
};
const formData = new FormData();
formData.append('file', file)
formData.append('attributes', attributes)
const instance = axios.create({
headers: {
'Authorization': 'Bearer REMOVED'
}
});
let uploadUrl = 'https://upload.box.com/api/2.0/files/content';
instance.post(uploadUrl, formData).then((res) => {
console.log(res);
});
instance.get('https://api.box.com/2.0/folders/8***phone number removed for privacy***').then((res) => {
console.log(res);
})
instance.post('https://api.box.com/2.0/folders', { "name": "NewFolder4", "parent": { "id": "0" } }).then((res) => {
console.log(res);
})
}

