Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell SharePoint 2010 listdata.svc to return JSON via URL?

I need the following URL to return JSON: https://mysite/_vti_bin/listdata.svc/Pages

I've tried added the following to the URL (per a blog online but didn't work): https://mysite/_vti_bin/listdata.svc/Pages?format=JSON

It always returns XML. Also, I'm not calling the web service via C# or JS code. I'm using a rapid app dev platform that has built-in API consumption. All I need is JSON to be returned (given a URL structure) and I got what I need. Thanks.

like image 434
Josh Avatar asked Feb 08 '23 14:02

Josh


1 Answers

By default SharePoint 2010 REST service returns results in XML format. To get the results in JSON format, include an Accept header set to application/json;odata=verbose.

Example

url: http://site url/_vti_bin/listdata.svc/ListName,
method: GET
Headers:
    accept: "application/json;odata=verbose"

Result

enter image description here

like image 89
Vadim Gremyachev Avatar answered Feb 12 '23 09:02

Vadim Gremyachev