Skip to content

Instantly share code, notes, and snippets.

@vgrem
Created March 22, 2014 10:28
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/9704591 to your computer and use it in GitHub Desktop.
Save vgrem/9704591 to your computer and use it in GitHub Desktop.
Delete operation in SharePoint 2010 REST
function deleteListItem(webUrl, listName, itemId, success, failure) {
getListItemById(webUrl,listName,itemId,function(item){
$.ajax({
url: item.__metadata.uri,
type: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"X-Http-Method": "DELETE",
"If-Match": item.__metadata.etag
},
success: function (data) {
success();
},
error: function (data) {
failure(data.responseJSON.error);
}
});
},
function (error) {
failure(error);
});
}
//Usage: delete Task with Id=3
deleteListItem('https://contoso.sharepoint.com/project/','Tasks',3,function(){
console.log('Task has been deleted');
},
function(error){
console.log(JSON.stringify(error));
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment