Question

I've been working on a project that sends data to the server and receives a return value of JSON data. Unfortunately when I try to use HttpPost it returns as xml and not JSON.

I was able to fix the problem by using HttpGet.

I am just curious if it is possible to return JSON data using HttpPost? Can anyone enlightened me? I've been Googling around for a while but still unable to find any answers to my question.

P.S. Please don't flag my question.

Was it helpful?

Solution

The problem is not your HttpPost or HttpGet, the key point here is your server. When it receives a POST it is programmed to return a XML-like string and if it gets a GET it will return a JSON-like string

OTHER TIPS

If it is a third-party server, make sure you set the corresponding parameters for the format you would like to retrieve. Typically this is the Accept header. If it is your own server, zozelfelfo is right and it depends on your implementation, but not on the HTTP verb.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top