Welcome to the new Box Support website. Check out all the details here on what’s changed.

400 "bad request" API search when a user from outside my company account shares a document with me..

Answered
New post

Comments

3 comments

  • tobywun

    Please note the ***email address removed for privacy*** was simply an example to illustrate it was   exampleuser(a)hotmail.com

    0
    Comment actions Permalink
  • mwiller

     I just tested this, and it looks like you need to provide a `limit` query parameter with the `offset`, like this:

     

    `GET /search?query=external&limit=100&offset=100` # this gets the 100th through 199th results

    0
    Comment actions Permalink
  • tobywun

    OK, so I didn't include the limit in the example I gave, but this was me trying to give a clean example, so apologies if that was misleading, our code was actually adding in a limit.

     

    The example should have been more like curl https://api.box.com/2.0/search?query=doc&offset=24&limit=24

     

    Or in actual fact what was causing the issue curl https://api.box.com/2.0/search?query=doc&offset=23&limit=24

     

    It seems that the problem was the 400 error is due to the offset (23) not being a multiple of the limit (24). For the initial call (first page) we request 24 documents, but when the external document exists the API only returns 23 even though there are > 100 results in total, probably due to the externally shared document being skipped for some reason? The offset requested by the code is the number of documents returned in the first call, but the page length, therefore the limit, was still 24, so this causes the 400, as the offset is then not being a multiple of the limit.

    Thanks for your help.

     

    There is still the issue that the API does not seem to return the document shared from the external user.

    0
    Comment actions Permalink

Please sign in to leave a comment.