How can I retrieve via REST service in SharePoint item column values in JSON:

This is my snippet:

  url: '/_api/web/lists/getbytitle("my list")/items/getbyid(3)',
  type: 'GET',
  header: {'Accept': 'application/json;odata=verbose'},
  success: function(data) { alert(data.title); }

It's not working, any help?

  • 2
    You really need to put some more context into your questions - from that snippet its really not clear how you are calling the services. We can guess, but might be wrong so include a little more detail – Ryan Jul 2 '13 at 15:03
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>   
 function restEndPoints2013(){

    url: "http://site/_api/Web/Lists/GetByTitle('listName')/items(3)", 
    type: "GET",
    headers: {"accept": "application/json;odata=verbose"},
    success: function(data){
        $.each(data.d.results, function(index, item){  
    error: function(error){

Dump this into an HTML editor and upload it to a server and see what happens.


Iterate through data.d.results:

function(data) {
$.each(data.d.results, function(i,result) {
//get item property
var strTitle = result.Title;
  • Thanks Nadeem, I tried it and I got the error in JavaScript that it can't get the property results for the undefined data.d It can't know what is d in the data. – SharePoint Freak Jul 2 '13 at 22:58
  • any more ideas? – SharePoint Freak Jul 2 '13 at 23:18

You can easily use jQuery for this. At first you build your Query String:

//For the Element with the ID 1
var urlQuery = "https://www.url.i/site/_vti_bin/ListData.svc/Listname?$filter=ID eq 1"; 

Then you can access the items from the list:

    function (data) {
       $.each(data.d.results, function (i, item) {
          var title = item.Title;

EDIT 1: Fixed it, should work for SP2010.

EDIT 2: For SP 2013 you can use this Query String:

http://url.i/sites/siteName/_api/web/lists/getByTitle('listName')/items?$filter=Id eq 1

Then you should get the element as XML. If you put

accept: application/json;odata=verbose

in the HTTP-Header you get the result as JSON

Here are some more information about Rest in SharePoint 2013

  • Thanks Mbauer, but I need to pass a parameter to the list with the ID of the item and get the title, so what am using is something like this: $.ajax({ url: '/_api/web/lists/getbytitle("my list")/items/getbyid(3), type: "GET", header: {"Accept": "application/json;odata=verbose"}, success: function(data){ alert(data.title);}, but it's not working – SharePoint Freak Jul 2 '13 at 22:44
  • the data returned in xml not json..! – SharePoint Freak Jul 2 '13 at 23:49
  • what SharePoint version are you using? – mbauer Jul 3 '13 at 5:36
  • Foundation 2013 – SharePoint Freak Jul 3 '13 at 17:09

may be you should use $.ajax instead of $.getJSON and replace "header: {"Accept": "application/json;odata=verbose"}" by " dataType: 'json' " in order to get the response in JSON format. Besides, try to add to your ajax the parameter "async: false" to make the request synchronous because you are trying to get the value from an empty object.

  • Won't work very well against SharePoint REST API without the header proposed by mbauer! – Robert Lindgren May 8 '14 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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