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 with valid X-RequestDigest

sp13test 281 Reputation points
2021-02-04T15:25:48.707+00:00

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
                });
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,576 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    2021-02-05T02:28:40.12+00:00

    Hi @sp13test ,

    There is a typo in X-RequestDigest, it should be like this:

    "X-RequestDigest": $("#__REQUESTDIGEST").val()  
    

    Then please try again to see if it works.

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Jyothi Sakre 1 Reputation point
    2021-07-09T00:37:04.497+00:00

    Same issue with me

    I'm using below code but still issue persists

    X-RequestDigest": $("#__REQUESTDIGEST").val()

    Any help?

    0 comments No comments

  2. Ganesh Patare 0 Reputation points
    2024-03-31T12:03:28.0833333+00:00

    I got fix by including my input file to form tag with SharePoint:FormDigest tag.

    Below is my working code

    <form class="frmView" style="margin-top:80px">

    <SharePoint:FormDigest ID="FormDigest1" runat="server"></SharePoint:FormDigest>	
    
    	<input type="file" class="custom-file-input" id="attachment" name="filename" />
    
      				<button id = "addFileButton" type="button" class="btn btn-primary" onclick="uploadFile()">Submit</button>
    
      				
    
    			 			
    

    </form>

    0 comments No comments