Skip to content

Instantly share code, notes, and snippets.

@vgrem
Created March 22, 2014 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrem/9703400 to your computer and use it in GitHub Desktop.
Save vgrem/9703400 to your computer and use it in GitHub Desktop.
Read operation in SharePoint 2010 REST
function getListItemById(webUrl,listName, itemId, success, failure) {
var url = webUrl + "/_vti_bin/listdata.svc/" + listName + "(" + itemId + ")";
$.ajax({
url: url,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
success(data.d);
},
error: function (data) {
failure(data.responseJSON.error);
}
});
}
//Usage
getListItemById('https://contoso.sharepoint.com/project/','Tasks',2,function(taskItem){
console.log(taskItem.TaskName);
},
function(error){
console.log(JSON.stringify(error));
}
);
@guscanales
Copy link

hi vgrem.

how can i set the user and password credentials? or how can i get the key to connect with this to a sharepoint server without anonymous access??

@MickVazovsky
Copy link

How using this code all items, here ony 1..((

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment