Introduction
I have created a “City” list and added an item in the Title column. Now, we will get the data of list items through REST API in Microsoft Flow.
Scenario
In SharePoint Online custom list, when an item is created, a mail needs to be sent using the Title column in the mail. This needs to be achieved through Microsoft Flow.
Process
Let’s move to Microsoft Flow.
Step 1
Click the URL
here to go to Microsoft Flow. The following screen appears. In the left navigation, select Templates. From the main window, now, select the
"Send an email when a new item is created in SharePoint" template.
Steps 2
After selecting the template, the following screen appears. Click the "Continue" button.
Step 3
On the next screen, add a new action by clicking the
sign and expand.
Start Microsoft Flow implementation step by step
- In the Flow first block, the following section appears. Add the site address of your relative site collection URL and select the List name in which you implemented the operation.
- In the second block, the following section appears In this section, declare the variable name and set the created itemId.
- The third block asks us to add the ‘Send an HTTP request to SharePoint’ action to execute REST API on current created ItemId.
- Lots of people are confused about how to parse the JSON Schema data. Let us see the steps on how to get the Parse JSON Schema data.
- Open the site in a browser and press F12 to open the browser console prompt. Add the following JavaScript code. This code will add a jQuery CDN in the head section of your page which will help us to call the REST API.
- var element = document.createElement("script");
- element.type = "text/javascript";
- element.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";
- document.head.append(element);
- $.ajax({
- url: "https://pointerone.sharepoint.com/sites/SPFXDemo/_api/web/lists/GetByTitle('City')/items(1)",
- method: 'GET',
- headers: {
- "Accept": "application/json; odata=verbose",
- "content-type": "application/json; odata=verbose",
-
- }, success: function (data){
- debugger;
- }});
In the fourth block, we need to add the ‘Parse JSON’ action to execute the REST body Schema.
Click the above screen pop up. Use sample payload to generate schema link. Then, the following screen pops up. Here, paste the JSON.stringify(data) in the below block. Click the "Done" button.
In the last section, we add the ‘send mail’ action. Here, let us set the To, Subject, and Body fields and save the flow.
Output
- Add an item in the City List.
- See the Microsoft Flow status.
- In Outlook mail, the screen appears with the currently added city name.
Note
Limits and configuration in Microsoft Flow post