jeudi 12 février 2015

Cannot delete attachment from a list item from a sharepoint online app

I get a success message after running the following displayed below. However, when I go and verify the list item the file is still there. If I try the client side of this code, the file gets deleted, I'm not sure if I'm missing something.


function initialize(){ var scriptbase = hostweburl + "/_layouts/15/";

$.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);


function execCrossDomainRequest() {

var executor = new SP.RequestExecutor(appweburl);

var digest = $("#__REQUESTDIGEST").val();



executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('TestList')/getItemById(1)/AttachmentFiles/getbyFileName('test - -File.xlsx')?@target='" + hostweburl + "'",
type: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"X-Http-Method": "DELETE",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
alert("success: " + JSON.stringify(data));
},
error: function (err) {
alert("error: " + JSON.stringify(err));
}
});


} }


Aucun commentaire:

Enregistrer un commentaire