Basic REST request to SharePoint using Postman

I wanted to share this tutorial on how to consume SharePoint’s REST service using the HTTP client Postman. I have to do this on a daily basis but keep forgetting the details and have to Google it, but Google is not that helpful and I get results that are unnecessarily complex.

I’m using a development environment and am logged in as a user with permission to read the data I’m requesting, which is a requirement. It takes to steps, first we have to prove that Postman is authenticated and then we can request the data.

Getting authenticated

Type in

into the input field and make sure it’s a POST-request. Now we need to add a header, to tell SharePoint what kind of data we want back, so click on the “Headers” button at the top right corner. At the left side on the new lines that appear, enter Accept. At the right side enter application/json; odata=verbose. It should now look something like this:

rest-1

Then click send and you get the results back. Copy the FormDigestValue, which is a really long string ending with a date and time. Mine looked like this:

Getting data

Change the URL to, for example,

and it should still be a POST-request. The accept-header should look the same, but now you need to add the FormDigestValue as another header. To the left, enter X-RequestDigest and to the right enter the value you copied before. Then all you have to do is click send, and the data appears. The finished result:

rest-2

4 reaktion på “Basic REST request to SharePoint using Postman

  1. ash

    Thanks for the useful post. However the first part was sucessful, 0xDBA2F14E8C721FE5E45995233E19B3B0C47F7BBEC1FA7933C525F19BD868BB1D06A1E28BBD7BB367C629B34754925D443411C4558D8AC7B6E97F248DC9710E5E,24 Apr 2014 22:10:32 -0000
    but for the second part I receive the error below

    -2130575251, Microsoft.SharePoint.SPException
    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.

    Any suggestions might help.

    Svara
  2. Stina QvarnströmStina Qvarnström Inläggsförfattare

    Hi! It looks like your token that you got in the first step either expired because you took too long, or that you tried to access a different site than the one you got the token from. Try to do it again without waiting between the steps and make sure the site you’re calling are the same in both steps!

    Svara
  3. ash

    Thanks for your reply. The site is the same for both requests and there is a delay of about 3-4 sec (time it took me to send the second request). Perhaps it is some setting on Sharepoint online I am wondering..

    Svara
  4. ash

    Sorry but my bad.. I was not paying attention to the fact that the X-RequestDigest was not entered in the Header Value section as it should be but in the Key Value section :( Thanks!

    Svara

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *

Följande HTML-taggar och attribut är tillåtna: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">