I used MVC4 Rest APi for my latest project. But I ran into one issue which I'm unable to figure out.
My request supports both JSON and XML format and I have no problem in getting a response from my request.
While testing I found out issue that while hitting this API using "Advanced Rest Client", even if I send request in JSON format, the response is always in XML format.
But if I use Fiddler, it works fine i.e JSON request gives JSON response and XML request gives XML response
Request headers
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
Content-Type: application/xml
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Response headers
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
Date: Mon, 21 Jul 2014 12:01:27 GMT
Content-Length: 340
I'm afraid the end users might face the same issue. So is there any way to fix this?
All I can find is to forcefully use only one format for my Web API to solve this. But I have to support both formats.
Is there a way to this?
Thanks