I have a RESTFULL type of web service which can return both xml and json responses.Whenever i request the service it returning me only xml response, So my question is how can i request only json response using NSURLConnection. Is there any way to do so, or this should be handled at web service side. And one more thing the web service don’t have specific extension in url like (http://[serviceURL].json neither http://[serviceURL].xml).
Thanks in advance and any guide lines would be greatly acceptable. Thank you.
Have you tried setting the “Accept” http header field for the request ? You can do that by using NSMutableURLRequest :
or you can try the “Content-Type” header field :
It depends on how header fields are handled on the server side.