We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.
Forum Discussion
tomglod
4 months agoExplorer | Level 3
Bad Request Errors Hints
So, I'm new to the dropbox API, and the work has been a giant pain. Mainly because of the design of the dropbox api and the unusual decisions that were made. I am writing this in hopes of saving so...
Greg-DB
4 months agoDropbox Staff
Thanks for the feedback!
For reference for anyone reading, if there are no parameters to send for an RPC endpoint like this, you can omit the request body as long as you also omit the "Content-Type" header (since there is no request body to describe).
To illustrate this, here's some examples of working usage of the mentioned /2/users/get_current_account endpoint, which doesn't require any parameters. The first way is the simplest way to call this endpoint:
# works, because no request body is sent, and accordingly no Content-Type is specified
curl -X POST https://api.dropboxapi.com/2/users/get_current_account \
--header "Authorization: Bearer <ACCESS_TOKEN>"
# works, because a request body is sent with the JSON "null" (since there are no parameters), with the corresponding "Content-Type: application/json"
curl -X POST https://api.dropboxapi.com/2/users/get_current_account \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data "null"
- tomglod4 months agoExplorer | Level 3
That may be true, but you may also see a "expecting Content-Type" error, urging you to include a content-type.
- Здравко4 months agoLegendary | Level 20
tomglod wrote:That may be true, ...
Hi tomglod,
It is definitely true! As Greg mentioned, meaning of content depends on content type. Empty string is definitely not valid JSON content type!!! Passing empty string as JSON is... a bug. To represent nothing, correct representation is null (by the way this is not a string - string "null" would be wrong too). Keep in mind that quotes that appear on command line (untagged) get stripped by the shell.
You can pass arguments as nothing when missing both content-type and the body as already discussed.
tomglod wrote:..., but you may also see a "expecting Content-Type" error, urging you to include a content-type.
Dropbox API cannot be "urging you to include content type"! If you have included inappropriate content type, error response will show you possible correct variants while suppose you want to pass something. Here the message is missing the option of missing content type - something that may be improved. If something else urge you though, try figure out where it comes from - it may be from your environment.
Good luck.
About Discuss Dropbox Developer & API
795 PostsLatest Activity: 3 days ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!