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)); | |
} | |
); |
This comment has been minimized.
This comment has been minimized.
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
This comment has been minimized.
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??