Archived Forum Post

Index of archived forum posts

Question:

http.PostJson content-type wrong?

Aug 16 '13 at 02:58

Using the (c++) http.PostJson() method, Chilkat uses (uncommon) "application/jsonrequest" as content-type. This seems to cause problems with some server frameworks. Shouldn't it be "application/json" according to RFC 4627?

Using http.AddQuickHeader("Content-Type", "application/json") fixes this problem, but it's just a workaround.


Accepted Answer

Use the PostJson2 method. See the online reference documentation.

CkHttpResponse *PostJson2(const char *url, const char *contentType, const char *jsonText);

The same as PostJson,except it allows for the content type to be explicitly provided. 
The PostJson method automatically uses "application/jsonrequest". If the application needs 
for the content type to be "application/json", or some other content type, then PostJson2 

Answer

Yes, thanx, can be done via JsonPost2. My documentation was too old.

But I think that content type "application/json" should be used by default in PostJson and other unusual content types (like jsonrequest) with PostJson2. Just a thought.