afrish
afrish

Reputation: 3306

Forbidden to create a folder via Box API

I'm trying to create a folder via Box API. Here is how my request looks like:

-------------- 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"}

Can somebody explain what is wrong with my request? In the response to other requests with the same Bearer header I receive correct results:

-------------- 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

And my application is configured to ask for read and write permissions.

Upvotes: 1

Views: 2184

Answers (2)

Aswathy
Aswathy

Reputation: 1

For Creating folder in Box.net using C#.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;



}

Upvotes: -1

Chirag B
Chirag B

Reputation: 2116

Could you change URL from

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

to

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

Upvotes: 3

Related Questions