Power Platform – Power Automate – How to verify status code return from the action – “Invoke an HTTP request”

Hi All,
Greetings for the day 🙂 LIFE IS BEAUTIFUL 🙂 I hope we all are safe 🙂 STAY SAFE, STAY HEALTHY 🙂
Today might be small and common finding, but since it took me the time for again and required bit research so this article 🙂
Background : In one of my Power Automate I need to use “Invoke an HTTP request” action and based on the return status code I need to send an email either success or failure.
Invoke an HTTP Request action :
- This action invokes an HTTP end point.
- We need HTTP with Azure AD connector as
- HTTP with Azure AD connector allows us get the resources from various web services using Azure Active Directory authentication
- To use HTTP with Azure AD connector we will require Power Automate premium license
- Invoke an HTTP Request action requires following parameters:
- Method : One of the HTTP verb – POST, GET, DELETE, PUT, PATCH
- URL of the request : Full relative URL of the resource. Ex. : To get all Groups we have Microsoft Graph REST API – https://graph.microsoft.com/v1.0/groups/
- Body of the request : Body of the request / parameters if any
Example :
- For demo purpose lets create a simple flow, we will trigger this flow manually
- We will fetch all the groups using Microsoft Graph REST API – https://graph.microsoft.com/v1.0/groups/
- From connector “HTTP with Azure AD“, add action “Invoke an HTTP request” as shown in below fig

- Specify following required details:
- Method – Get
- URL of the request – https://graph.mictosoft.com/v1.0/groups/
- We are ready to do first test run
- We will test it manually
- Click on “Test Flow” from right side pane and select option “Manually” as shown in below Fig
- In the right side pane we will get the details like connection as shown in below Fig
- Lets check the output of the action
- In output we will get
- statusCode – here 200 for success
- headers details
- body – having list of groups to which current account has the access
- so till here all is OK 🙂
- Now based on “statusCode” we need to send an email either success or failure
- so we need to get the “statusCode” and we will store in a variable
- Lets add new action “Initialize variable” as shown in below Fig
- Here variable name is – “StatusCode” as shown in below Fig
- We need to store the “statusCode” from the output of the action “Invoke HTTP request” in the “StatusCode” variable as shown in below Fig

- We will use “outputs” expression to read the “statusCode” from the output of action “Invoke HTTP request” an in below code snippet
outputs('Get_all_Groups')?['statusCode']
- Here, in “outputs” expression ‘Get_all_Groups’ is the action name which we renamed from “Invoke HTTP request” to “Get all Groups”

- Once we have “statusCode” we are ready to check the condition and send email as shown in below Fig
- So in this way based on the “statusCode” returned from “Invoke HTTP request” action we can execute the respective actions 🙂
I’ll stop here today 🙂
We have very good series on Power Automate – https://knowledge-junction.in/?s=power+automate OR https://knowledge-junction.in/?s=power+platform
We have very good series Microsoft Graph please have a look – https://knowledge-junction.in/?s=Microsoft+Graph
References:
Thanks for reading 🙂 If its worth at least reading once, kindly please like and share 🙂 SHARING IS CARING 🙂
Share In Teams:Enjoy the beautiful life 🙂 Have a FUN 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂
You must log in to post a comment.