Another Salesforce blog!!!

Salesforce, Apex

ASP.NET Web API to return JSON or XML data

Add the below code app_start event in global.asax file.In API Url add the query string.

new QueryStringMapping(“type”, “json”, new MediaTypeHeaderValue(“application/json”)));
new QueryStringMapping(“type”, “xml”, new MediaTypeHeaderValue(“application/xml”)));

for xml : http://localhost:49533/api/books?type=xml
for json: http://localhost:49533/api/books?type=json

Leave a Reply

Your email address will not be published. Required fields are marked *