禁止通过Box API创建文件夹

时间:2013-04-10 21:29:50

标签: box-api

我正在尝试通过Box API创建一个文件夹。以下是我的请求:

-------------- REQUEST  --------------
POST https://api.box.com/2.0/folders/0
Accept-Encoding: gzip
Authorization: Bearer [hidden]
User-Agent: Google-HTTP-Java-Client/1.14.1-beta (gzip)
Content-Type: application/json; charset=UTF-8
Content-Length: 36

-------------- REQUEST BODY ----------
{"name":"test2","parent":{"id":"0"}}

-------------- RESPONSE --------------
HTTP/1.1 403 Forbidden
Date: Wed, 10 Apr 2013 21:15:53 GMT
Content-Length: 224
Content-Type: application/json
Connection: keep-alive
Server: nginx
Cache-Control: no-cache, no-store

-------------- RESPONSE BODY----------
{"type":"error","status":403,"code":"access_denied_insufficient_permissions","help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Access denied - insufficient permission","request_id":"19725779175165d68967049"}

有人可以解释我的请求有什么问题吗?在对具有相同Bearer标头的其他请求的响应中,我收到了正确的结果:

-------------- REQUEST  --------------
GET https://api.box.com/2.0/folders/0
Accept-Encoding: gzip
Authorization: Bearer [hidden]
User-Agent: Google-HTTP-Java-Client/1.14.1-beta (gzip)

-------------- RESPONSE --------------
HTTP/1.1 200 OK
Date: Wed, 10 Apr 2013 21:15:53 GMT
Transfer-Encoding: chunked
Content-Encoding: gzip
Content-Type: application/json
Connection: keep-alive
Server: nginx
Cache-Control: no-cache, no-store

我的应用程序配置为要求读写权限。

2 个答案:

答案 0 :(得分:3)

您可以从

更改网址吗?
  

https://api.box.com/2.0/folders/0

  

https://api.box.com/2.0/folders

答案 1 :(得分:-1)

使用C#.net

在Box.net中创建文件夹

static string folderCreation(string APIKey,string authToken)     {

    RestClient client = new RestClient();
    client.BaseUrl = "https://api.box.com/2.0/folders";
    var request = new RestRequest(Method.POST);
    string Headers = string.Format("Bearer {0}", authToken);
    request.AddHeader("Authorization", Headers);
    request.AddParameter("application/json", "{\"name\":\"Youka\",\"parent\":{\"id\":\"0\"}}", ParameterType.RequestBody);
    var response = client.Execute(request);
    return response.Content;



}