0

We are having requirement to integrate SharePoint and service now (SharePoint 2013 On Premise).

Requirement is to post the data from service now to SharePoint 2013 custom list. We have shared rest API (Post method) URL with ServiceNow to post the data in SharePoint, but Service Now team is getting below error:

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.

Post analysis, we found that due to X-RequestDigest value in the request header we are getting above error (we are not using OAuth). Please let me know any way to set this property of X-RequestDigest in the header?

Note: We are getting error at Service Now side.

0

They can get the RequestDigest value by a post request at /_api/contextinfo

On return, the value will be in d.GetContextWebInformation.FormDigestValue

After getting this value, you can send it in header.

Example:

var requestToken = "";
$.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo",
    method: "POST",
    headers: { "Accept": "application/json; odata=verbose"},
    success: function (data) {      
         requestToken = data.d.GetContextWebInformation.FormDigestValue;
    },
    error: function (data, errorCode, errorMessage) {
        alert(errorMessage)
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.