cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know more about how you can find anything and protect everything? Check it out 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: 

Bad HTTP "Content-Type" header from the Dropbox API

Bad HTTP "Content-Type" header from the Dropbox API

VijayKumar E
Explorer | Level 3

When I try a request to Dropbox API(v2), I am getting this error ,

 

"message": "Error in call to API function  "users/get_current_account": Bad HTTP "Content-Type\" header: "application/x-www-form-urlencoded". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack"

 

I am referring the following DropBox Documentation link  and setting the Header as mentioned .  Can someone please

help what is the reason for the issue ?

 

I am getting the above error message for the following APIs 

 

/users/get_space_usage

 

users/get_current_account

 

5 Replies 5

Здравко
Legendary | Level 20

Hi @VijayKumar E,

The error message is descriptive enough, I think. For most API calls data are transferred in JSON form, not in urlencoded one. Seems you are trying to pass something in incorrect form. Even more, neither '/users/get_space_usage' nor '/users/get_current_account' require any parameters, so what are you actually trying to pass?! 🤔 In both cases authentication information would be enough. It's not an API call parameter, but independent header entry!

Try to post some code snippet reproducing the issue or raw HTTP headers for more details.

 

PS: May be useful try Dropbox API Explorer for get_current_account (for example). Click 'Show Code' button and select 'HTTP request' to see what has to be. 😉

Greg-DB
Dropbox Staff

Здравко is correct, it looks like your code/client is just sending the wrong "Content-Type" request header, and these endpoints don't take any parameters, so that header isn't required anyway. You mentioned you are attempting to set the header correctly, but it's possible whatever HTTPS client you're using is overriding that. You may need to refer to the documentation for your client for information on configuring it accordingly.

VijayKumar E
Explorer | Level 3

Hi ,

For the mentioned APIs '/users/get_space_usage' and '/users/get_current_account' I am not sending any data in the request. So why should I set the content-type as application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack" for the request ?

In both cases we are just passing the authentication information by referring DropBox Documentation .

By seeing the error message I tried the APIs by setting those content-type as application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack" but still it was not working .

When I tried the API by passing the content-type as empty string ( Content-Type : “” ) it’s working fine.

Здравко
Legendary | Level 20

@VijayKumar E wrote:

... So why should I set the content-type as application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack" for the request ? ....


You shouldn't set anything, actually.

 


@VijayKumar E wrote:

...
When I tried the API by passing the content-type as empty string ( Content-Type : “” ) it’s working fine.


Great! 👍 Seems you have found it. Maybe that's the way in your environment to disable content-type header sending together with empty query body. 🤷

humanclock
New member | Level 2

Yes, for anyone reading this...

 

If you are calling something that takes no parameters like: https://api.dropboxapi.com/2/users/get_current_account

 

you need to make sure either you:

1) Explicitly send NO Content-type header with your request so it is completely absent:

 

or

 

2) If you have an underlying framework in your code making the call that puts in a default content header, you need to explicitly override it and send a blank one ala Content-type: "" 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    humanclock New member | Level 2
  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    VijayKumar E Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?