cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error response is coming into different different format

Error response is coming into different different format

Shashi
New member | Level 2

Hi,

 

I have tried to get account through this API https://api.dropboxapi.com/2/users/get_account  using SOAPUI and passing account_id in request body.

 

{
"account_id":"dbid:AACCsTU3d_-j5rfgJkGLObJErDLctQmUZw0"
}

 

If account_id is incorrect but having 40 character then error is coming in to JSON formate

 

{
"error_summary": "no_account/.",
"error": {".tag": "no_account"}
}

 

If I am passing the account_id less then 40 character or more then 40 character then response is not coming into JSON. It is coming into text/plain.

 

<data contentType="text/plain; charset=utf-8" contentLength="144"><![CDATA[Error in call to API function "users/get_account": request body: account_id: 'dbid:bbCCsLObJErDLctQmUZw0' must be at least 40 characters, got 26]]></data>

 

Thanks,

Shashi Bala

3 Replies 3

Greg-DB
Dropbox Staff

The difference in response format, of JSON versus text, is expected in these different cases.

 

If the ID has the right format, the API will look it up, and return an error if it isn't found.

 

If the ID doesn't have the right format, e.g., it's the wrong length, it will fail validation, and the API won't bother trying to look it up.

 

You can check the response status code to see the different kinds of failures, and check the response Content-Type header to see what format the response body is in.

 

For example, using curl, these two calls look like: (responses trimmed for brevity)

curl -vX POST https://api.dropboxapi.com/2/users/get_account \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"account_id\": \"dbid:AACCsTU3d_-j5rfgJkGLObJErDLctQmUZw0\"}"

# < HTTP/1.1 409 Conflict
# ...
# < Content-Type: application/json
# ...
# {"error_summary": "no_account/.", "error": {".tag": "no_account"}}

curl -vX POST https://api.dropboxapi.com/2/users/get_account \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"account_id\": \"dbid:notvalidformat\"}"

# < HTTP/1.1 400 Bad Request
# ...
# < Content-Type: text/plain; charset=utf-8
# ...
# Error in call to API function "users/get_account": request body: account_id: 'dbid:notvalidformat' must be at least 40 characters, got 19

The API itself doesn't return the data/CDATA formatting in your post, so that is presumably coming from whatever tools you're using.

ShashiBala
Explorer | Level 4
Hi,

I am sending the request into JSON format then response should also come into JSON format, if ID validation fails or not. If it is not coming into JSON format then I don't think its good API design.

Thanks,
Shashi Bala

Greg-DB
Dropbox Staff
Thanks for the feedback! As it is designed the format of the response is not dictated by the format of the request, but rather can be determined programmatically by checking the response Content-Type. I'll send this feedback along to the team though.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    ShashiBala Explorer | Level 4
What do Dropbox user levels mean?