I am trying to update attachment of list item using REST API. I am getting the below error:
{"error":{"code":"-2130575257, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The specified name is already in use.\n\nThe document or folder name was not changed. To change the name to a different value, close this dialog and edit the properties of the document or folder."}}}
I am using the below code to update list item:
function saveFile(fileArrBuffer, fileName, itemId) {
var deferred = $q.defer();
$http({
method: 'POST',
url: _spPageContextInfo.webServerRelativeUrl + '/_api/web/lists/getbytitle(\'' + 'EmployeeList' + '\')/items(' + itemId + ')/AttachmentFiles/add(FileName=\'' + fileName + '\')',
headers: {
'Accept': 'application/json;odata=verbose',
'Content-Type': undefined,
'X-RequestDigest': spContext.securityValidation,
},
data: new Uint8Array(fileArrBuffer),
transformRequest: []
}).then(function successCallback(data) {
deferred.resolve(data);
console.log('Successfully saved.', data, false);
}, function errorCallback(error) {
deferred.reject(error);
console.log('Failed to save!!!.', error, false);
});
return deferred.promise;
}
I even tried to use overwrite=true
inside the rest url but I got error saying that property overwrite is not supported.