3

How to get json data from REST api in SharePoint 2013 list?

Regards,

2 Answers 2

2

Elaborating a bit on Roman's answer:

 jQuery.ajax({
    url: "http://thisRestServiceURL",
    type: "GET",
    headers: { 
        "accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    },

This would work for JQuery sending/receiving JSON Data.

5
  • Add this code to SharePoint site via CEWP? Thanks a lot for help.
    – Wilon
    Commented Mar 18, 2015 at 20:05
  • Sure you can, but if you're unsure of how to use JQuery to pull SharePoint JSON Data start learning, good resources: api.jquery.com/jQuery.ajax for JQuery ajax command and msdn.microsoft.com/en-us/library/office/jj163876.aspx for the SharePoint REST API overview.
    – tekiegreg
    Commented Mar 18, 2015 at 20:08
  • 1
    ...one last thing, you'll probably find the Script Editor Web Part: community.bamboosolutions.com/blogs/sharepoint-2013/archive/… easier.
    – tekiegreg
    Commented Mar 18, 2015 at 20:10
  • Thank you, I added script via Script Editor but after saved it, I see simple code on the page, nothig else?
    – Wilon
    Commented Mar 18, 2015 at 20:14
  • I'm presuming you've thought out your display mechanism, perhaps open a second question and show us the code you've written thus far?
    – tekiegreg
    Commented Mar 18, 2015 at 20:18
3

You should pass Accept header, for example: "accept": "application/json;odata=verbose"

2
  • Yes but can you give me more details?
    – Wilon
    Commented Mar 18, 2015 at 19:56
  • Which type of object model do you use?
    – Roman
    Commented Mar 19, 2015 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.