Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@guscanales guscanales commented May 27, 2015

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

This comment has been minimized.

Copy link

@MickVazovsky MickVazovsky commented Feb 5, 2016

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
You can’t perform that action at this time.