Box API 2.0 Set shared_link returns 404

Recently I have been playing with Box.com's API version 2.0.

According to the official description in this document, I can set "access" to "Open" for a file successfully.

However, if I change it to either "company" or "collaborators", the server returns a response saying HTTP 404 not found as the following shows.

{
   "type":"error",
   "status":404,
   "code":"not_found",
   "help_url":"http:\/\/developers.box.com\/docs\/#errors",
   "message":"Not Found",
   "request_id":"609097837503b1dabc4d0c"
}

And I cannot figure out what exactly does "not found" means by this message.

This is the request body I sent that is OK

{
   "shared_link":{
      "access":"Open",
      "permissions":{
         "download":true,
         "preview":true
      }
   }
}

This is the request body that returns me error

{
   "shared_link":{
      "access":"company",
      "permissions":{
         "download":true,
         "preview":true
      }
   }
}

I am wondering whether its something I should not do or it is just a bug in the api.

Thanks in advance for any response.

================================

Some update to the question.

I am afraid it is not a case related problem though the example on the document when I saw them do use uppercase "Open".

In my situation, either using "Open" or "open", I can successfully set the sharelink without any problem.

However, the behavior of following cases is a little bit odd to me.

case 1: Setting both properties( download and preview) in permissions to false returns 404 (setting only one of them to true works properly)

{
   "shared_link":{
      "access":"Open",
      "permissions":{
         "download":false,
         "preview":false
      }
   }
}

In following cases, for illustrating purpose I first set "access" as "Open".

case 2: Setting "access" to "Collaborators" returns 404 not found

case 3: Setting "access" to "collaborators" Works ok, but the json response did not correctly shows the "access" as "collaborators"

Following is the excerpt from the response of case 3, "access" is still "Open"

    shared_link": {
    "url": "https://www.box.com/s/03a47eb4b7dce0439d7f",
    "download_url": "https://www.box.com/shared/static/03a47eb4b7dce0439d7f.pdf",
    "password_enabled": false,
    "unshared_at": null,
    "download_count": 0,
    "preview_count": 0,
    "access": "Open",
    "permissions": {
        "download": true,
        "preview": true
    }

"Company" seems the same with previous cases so I stop here.

And out of curiosity I set the "access" to arbitrary characters other than those mentioned on the document(I tried words like "pp", "c", "test"), interestingly the server seems all returns 200:OK but the json response remains "access":"Open". Rather confusing.

Answers


Turns out that the "access" parameter was case-sensitive. We've now fixed that, so that "Open" and "open" etc both work.

It turns out that you are also exposing a couple of tricky edge cases around file-sharing. There are some security settings that you can set, such as the "Folder Properties: Security" setting that says "Restrict shared links to collaborators only."

It turns out that if you have set this setting, that API calls to set the "access" to "open", we'll return a 404. We'll work on making that a more informative error (like a 403, access denied).

As for the rest of the cases.

case 1: Our web-ui restricts you from setting some of those combinations (like download=false and preview=false) because when we built the sharing features, we didn't think it would make sense to have a non-downloadable, non-previewable file.

case 2 (and part of case 3): setting to "Collaborators" or "collaborators" should work fine now. Bug was fixed.

case 3: setting to "co" or "foo" was defaulting to "Open." We've now changed that to return an error (404 again).

Hope that helps.


Need Your Help

jScroll for infinite-scrolling in Rails

javascript jquery ruby-on-rails infinite-scroll

I'm new to Rails and javascript. I've developed a small application in ruby on rails which searches for products in the database using solr's sunspot. I used to display the contents using kaminari's

ASP.NET MVC : Sending information to make a RedirectToAction

asp.net-mvc-2 redirect

I need to send data before making a "RedirectToAction" to the new view, and do not want the data being sent by "GET".