Calling Rest API in SharePoint Online to update some field value, but it throws this error:
{"readyState":4,"responseText":"{\"error\":{\"code\":\"-2130575251, Microsoft.SharePoint.SPException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again.\"}}}","responseJSON":{"error":{"code":"-2130575251, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again."}}},"status":403,"statusText":"error"}
I think I have the valid X-RequestDigest:
$.ajax({
url: requestUri,
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});