0

I'm trying to make a POST call via AJAX to create an item on my Sharepoint site.
I've got the call to .../_api/contextinfo and it is indeed returning a FormDigestValue.

Using this value, I'm adding it to my header, X-RequestDigest.

When I hit the code, I get a failure:

{code: "-2130575251, Microsoft.SharePoint.SPException", message: {lang: "en-US",…}}

"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."

I've tried this in Postman, and again, same problem.

Everywhere online says you need the FormDigestValue, which I have, and am using it correctly (I've done this via Postman on another site). But it still doesn't work.

Any suggestions would be great!

Justin Warner
  • 849
  • 2
  • 10
  • 20
  • How you execute the POST ? jQuery or Sharepoint JS ? From where you execute the POST ? A sharepoint page or an external page ? – Max Apr 09 '16 at 13:50
  • I'm using jQuery and executed from Postman. – Justin Warner Apr 11 '16 at 22:27
  • You need the security token [See this stackoverflow article](http://stackoverflow.com/questions/22159609/how-to-get-request-digest-value-from-provider-hosted-app) – Max Apr 11 '16 at 23:53
  • Hey Max, I do have the FedAuth and rtFa which the article you linked to says I would need. So it doesn't look like an auth problem. – Justin Warner Apr 12 '16 at 20:04
  • As an added note, it does work with Powershell, the only difference in web requests (When using Fiddler) is in Powershell I'm using SPOIDCTR and not FedAuth with rtFa. But that's because I'm using a username/password. – Justin Warner Apr 12 '16 at 21:07
  • Another note: I've gotten init.js imported and using UpdateFormDigest to get the Digest token. It's still not working with this new value. – Justin Warner Apr 13 '16 at 16:53

1 Answers1

0

My answer probably won't fix yours, but make sure you pass in the correct value for your first argument for UpdateFormDigest. In my case, I needed to change the value to: window["_spPageContextInfo"].webServerRelativeUrl.

Justin Warner
  • 849
  • 2
  • 10
  • 20