Thursday, 31 July 2014

Remove a SharePoint List Item Attachment in SharePoint 2013 Using REST


function fileDelete() {
var listName="Mylist";
var id="20";
var fileName="Myfile.doc";
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items(" + id + ")/AttachmentFiles/getbyFileName('" + fileName + "')?@target='" + _spPageContextInfo.siteAbsoluteUrl + "'",
type: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"X-Http-Method": "DELETE",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function () {
console.log("Done");
},
error: function (err) {
console.log(JSON.stringify(err));
}
});
}
view raw gistfile1.js hosted with ❤ by GitHub