How to call an HTTP request to SharePoint in Microsoft Flow

Hi readers, hope you all are doing well and enjoying Microsoft Flow & PowerApps. Today we will see “How to call an HTTP request to SharePoint in Microsoft Flow”. In this, we will create and delete an item into SharePoint custom by calling HTTP requests via Microsoft Flow. You can refer a link for complete basic operations using SharePoint REST endpoints. In our last blog, we had seen how to create a Flow and associate it with the PowerApps. We are using the “States” custom list here to add and delete an item using an HTTP request.

I will not go into the details on how to create PowerApps and associate a Flow with it, because we have already seen this in our earlier blogs. if you all haven’t seen yet, please go through it for more details.

Create Flow

We will create two Flows, first Add Item Flow and second Delete Item Flow in order to create and delete items in the SharePoint custom list. And both the flows will be associate with the button trigger action of a PowerApps solution.

  1. Add Item Flow – Navigate to the edit page of MS flow and create a flow as shown in the below screenshot.

HTTP request to SharePoint

Figure 1.

2. Field details used in the above screenshot are provided below.

 Site Address: <Your SharePoint Address>

Method: POST

Uri: /_api/Web/Lists/getbytitle('States')/Items
Headers: Content-Type: application/json;odata=verbose and Accept: application/json;odata=verbose
Body: { __metadata:
{
type: "SP.Data.StatesListItem"
},
Title: "Test",
District: "Test 2"
}

In the body, we can pass the Title and District value as dynamic from PowerApps itself as well.

Once you are done with the above steps then try to test run the flow. In flow history, you will able to see that it has been successful and created an item into the SharePoint list as shown below.

Figure 2.

3. Now we will see how to delete an item using flow by calling an HTTP request. Create a “Delete Item Flow” as shown in the below screenshot.

HTTP request to SharePoint

Figure 3.

4. Field details for delete item is given below.

Site Address: <Your SharePoint Site Address>

Method: POST
Uri: _api/web/lists/GetByTitle('States')/items(@{triggerBody()['SendanHTTPrequesttoSharePoint_Uri']}) --> @{triggerBody()['SendanHTTPrequesttoSharePoint_Uri']} is a dynamic value to pass the item ID from PowerApps system.
Headers: X-HTTP-Method: DELETE and IF-MATCH: *

Once we are done with the above configuration then we will run the workflow. When we try to test run the workflow it will ask for the Item ID which needs to be deleted as shown in the below figure.

HTTP request to SharePoint

Figure 4.

Conclusion

After providing the item ID, the related item will be deleted from the list. Similarly, we can update and view the items as well.

Hope you guys enjoyed this article, please share and subscribe to our site for more stuff on Flow and PowerApps. You guys can also comment on your real-time issues on PowerApps and flow.

Sharing is Caring

2 thoughts on “How to call an HTTP request to SharePoint in Microsoft Flow”

Leave a Comment

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

Scroll to Top