I am making a custom "Delete item" button for my list. The issue I am facing is that when the user attempting to delete the item does not have the permission to do so, besides the API failing, I think the server responds with a 401 unauthorized or the response header contains WWW-Authenticate
which makes the browser display an authentication prompt besides my custom error handler. My question is, how do I supress that prompt without doing any server-side changes?
Here is my example JavaScript code where I make the REST call:
$.ajax({
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getbytitle('" + listName + "')/items(" + id + ")/recycle()",
type: "POST",
headers: {
"ACCEPT":"application/json;odata=verbose",
"Content-Type":"application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH":"*"
},
xhrFields: { withCredentials: true },
success: function(data) {
elem.remove();
},
error: function(error) {
alert(error.responseJSON.error.message.value);
}
});
Thank you very much.