I'm implementing an application that does REST calls to a server to get a JSON response. If I do these calls connected to my home's Wi-Fi connection I get the result WITHOUT headers:
{"id":"ohig40o45h6c2a5d9rdhsft2v7","module_name":"Users", ...}
But if I do these calls using my phone's 3G connection I get the response with all the headers:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<pre xml:space="preserve">
{"id":"ohig40o45h6c2a5d9rdhsft2v7","module_name":"Users", ...}
</pre>
</body>
</html>
I want to get the body message (without the "pre" tags). Is there an easy way to do it? Why do I get the headers only if I use 3G connection?
Thanks.
I know it's an old question, but I had the same problem and here is the solution:
Just add at the beginning of your webservice the headers to inform that the response is JSON. If you are using PHP here is the example:
<?
header('Content-type: application/json');
//Your webservice code here
?>
Hope it helps!!