Can't Create folders with Box API
I'm using the Box APIs to perform some operations from a browser. I can upload, replace, list, download and delete files just fine. I'm running into problems with creating folders.
Before creating a folder I do query to see if it already exists. Once I see it doesn't I issue a request to create the folder and I Get back the following.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://' is therefore not allowed access. The response had HTTP status code 400.
Looking in the settings for the application I see that I've got my domain already listed in the CORS settings (if it were not I imagine the other file operations would have failed). Why am I getting this response and how do I resolve the problem behind it?
var createUrl = "https://api.box.com/2.0/folders?fields=name,id"; $.ajax( { "method":"POST", "url": createUrl, "data": { "name": name, "parent": { "id": parentFolderID } }, "headers": { "Access-Control-Allow-Origin": origin , "Access-Control-Allow-Credentials": true }, "beforeSend": function (xhr) { xhr.setRequestHeader('Authorization', 'Bearer ' + token.AccessKey); xhr.setRequestHeader("Access-Control-Allow-Origin", origin) }, "success": function (e) { }, "error": function (e) { } });
Response Headers
POST /2.0/folders?fields=name%2cid HTTP/1.1
Host: api.box.com
Connection: keep-alive
Content-Length: 52
Origin: https://localhost:44390
Authorization: Bearer xxxxxx
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Access-Control-Allow-Origin: https://
Accept: */*
Access-Control-Allow-Credentials: true
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Referer: https://localhost:44390/Playlist/Edit/d4b6664edc
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8
Request Headers
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8,ja;q=0.6
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://
Authorization:Bearer xxxxxxxxxx
Connection:keep-alive
Content-Length:52
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:api.box.com
Origin:https://
Referer:https:///Items/Edit/d4b6664edc
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
サインインしてコメントを残してください。
コメント
0件のコメント