delete list item attachments using REST api


  • Hi,

    How can we delete List item attachments in sharepoint online using REST api? i want to delete only specific attachments(based on the attachment name) but not all attachments.

    Thanks, PVSAVSG.

    • Edited by pvsavsg Wednesday, June 15, 2016 7:14 PM added more information
    Wednesday, June 15, 2016 7:13 PM

All replies

  • You can delete specific file by filename using the following rest

        function DeleteItemAttachmentByFileName(RequestsLstTitle, ItemId, FileTitle) {
            var Dfd = $.Deferred();
            var RestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + RequestsLstTitle + "')/GetItemById(" + ItemId + ")/AttachmentFiles/getByFileName('" + FileTitle + "')  ";
                url: RestUri,
                type: 'DELETE',
                contentType: 'application/json;odata=verbose',
                headers: {
                    'X-RequestDigest': $('#__REQUESTDIGEST').val(),
                    'X-HTTP-Method': 'DELETE',
                    'Accept': 'application/json;odata=verbose'
                success: function (data) {
                error: function (error) {
            return Dfd.promise();

    Friday, October 14, 2016 10:12 AM
  • I have tried this solution from PowerShell with the same headers,  but using the method POST, and it worked, however I would like to know how to perform the recycle action, so, instead of deleting the item permanently this would be moved to the recycle bin. Please if you have any solution for what I need, comment it.
    Thursday, June 15, 2017 4:49 PM
  • I try to follow that function but i have error and return [Object][Object]
    Wednesday, November 15, 2017 3:49 AM
  • Friday, December 8, 2017 4:04 AM
  • Hi,

    Did you ever figure out how to perform the recycle action on attachments using REST? I have the same issue with it being permanently deleted.

    Thanks :-)

    Wednesday, January 9, 2019 4:45 PM