Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

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.

Microsoft Flow - How To Get SharePoint List Item 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.
 
Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

Steps 2

After selecting the template, the following screen appears. Click the "Continue" button.
 
Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

Step 3

On the next screen, add a new action by clicking the Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow sign and expand.
 
Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow
 

Start Microsoft Flow implementation step by step

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

    Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

  2. In the second block, the following section appears In this section, declare the variable name and set the created itemId.

    Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

  3. The third block asks us to add the ‘Send an HTTP request to SharePoint’ action to execute REST API on current created ItemId.

    Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

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

    1. 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. 
      1. var element = document.createElement("script");  
      2.     element.type = "text/javascript";  
      3.     element.src  = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";  
      4.     document.head.append(element);  

      Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

  • Call the REST API and in debugger mode, assign JSON.stringify(data) to the variable. Don’t stop debugger before assigning the JSON data to declare variable (jsonvar). Copy the variable value.

 

  1. $.ajax({    
  2.             url: "https://pointerone.sharepoint.com/sites/SPFXDemo/_api/web/lists/GetByTitle('City')/items(1)",    
  3.                   method: 'GET',    
  4.              headers: {    
  5.                 "Accept""application/json; odata=verbose",    
  6.                 "content-type""application/json; odata=verbose",                       
  7.     
  8.             }, success: function (data){   
  9.                 debugger;  
  10.             }});  
Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

In the fourth block, we need to add the ‘Parse JSON’ action to execute the REST body Schema.

Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

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.

Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

 

In the last section, we add the ‘send mail’ action. Here, let us set the To, Subject, and Body fields and save the flow.

Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

Output

  1. Add an item in the City List.

    Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

  2. See the Microsoft Flow status.

    Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

  3. In Outlook mail, the screen appears with the currently added city name.

    Microsoft Flow - How To Get SharePoint List Item Through Rest API In Microsoft Flow

Note
Limits and configuration in Microsoft Flow post


Similar Articles