Calling the SharePoint REST API in a Microsoft Flow

Published on Author Rob Windsor3 Comments

I’ve been doing a lot of work with Microsoft Flow lately and I came across a situation where I needed to make a call to the SharePoint REST API to move a list item from one folder to another. There’s currently no move action in Flow but there is a moveTo function in the REST API.

I did some Googling and I found several posts that showed how to register an add-in, make app-only permissions requests for the add-in, trust the add-in, and then use the HTTP action in Flow to get the bearer (access) token using the add-in Client ID and Secret so you could then use the HTTP action to make the REST API call. I followed the steps described in the posts and was able to make the REST API call to move the list item. This is one example of the posts to which I’m referring: How to Call the SharePoint REST Webservice from Microsoft Flow.

A short time later I was looking for something else when I noticed the ‘Send an HTTP request to SharePoint’ action. This action could have been named ‘Make a SharePoint REST API Call’ because that is exactly what it enables you to do – without having to go through all the setup described above.

In the example below I’m using the ‘Send an HTTP request to SharePoint’ action to execute a CAML query. Note that I am not passing the form digest in the headers. This is not required from what I’ve seen so far.

Send an HTTP request to SharePoint

3 Responses to Calling the SharePoint REST API in a Microsoft Flow

  1. Nice 🙂

    I guess that this will make it kinda trivial to set up a timer based Flow that calls the SharePoint Search REST API, ferching all Tasks across the Tennant or Site Collection and for each of them checking that owner is still an not-blocked AAD user That will make out Governance sooo much better.

  2. HI sir,

    i checked with your way, thank you for your article but face error

    {“odata.error”:{“code”:”-1, Microsoft.SharePoint.Client.InvalidClientQueryException”,”message”:{“lang”:”en-US”,”value”:”Not well formatted JSON stream.”}}}
    clientRequestId: becff714-9c4a-47d3-ae62-45c1c09f17b9
    serviceRequestId: 0ff9819f-505e-b000-9479-db29ed69360d

    Please help me to get me out of this error

    • Could you send a screen capture of the action? If you can’t add the screen capture to the comment here, then send it to me (@robwindsor) on Twitter.

Leave a Reply to Rob Windsor Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.