Reputation: 34
I'm trying to gather some data from Dropbox however finding that the service is returning a message that the request isn't in the correct format.
I can successfully retrieve data from the service using a call which doesn't require JSON however when I try making a call which includes JSON the service replies it's not in the correct format.
I'm using PostAsJsonAsync method in the HttpClient class.
response = await client.PostAsJsonAsync("/1/team/members/list", "{ \"limit\" : 100 }");
json = System.Web.Helpers.Json.Decode(await response.Content.ReadAsStringAsync());
The service responds:
error = "Content-Type must be \"application/json\". Got application/json; charset=utf-8"
Upvotes: 1
Views: 261
Reputation: 60153
For now, you'll need to set the Content-Type
header to exactly application/json
. I suspect we'll be able to relax the constraint in the future so application/json; charset=utf-8
will also work.
Here's a similar question on Microsoft's forums (but no helpful answer): http://forums.asp.net/t/1982431.aspx?How+to+remove+charset+utf8+from+Content+Type+header+generated+by+HttpClient+PostAsJsonAsync+. I'd suggest just using a different method which allows you to set the Content-Type
header explicitly.
Upvotes: 1