Using HTTP Requests in Power Automate for API Calls

Loading

Overview

Power Automate allows you to integrate with external services and APIs using HTTP requests. This is useful for:
Calling third-party APIs (e.g., Google, OpenAI, Salesforce, etc.)
Interacting with Microsoft services (e.g., Microsoft Graph API, SharePoint, OneDrive)
Sending data to external applications
Retrieving or updating data from a database or web service


1️⃣ What Are HTTP Requests?

HTTP requests allow Power Automate to communicate with APIs over the internet. They follow this format:

HTTP MethodDescriptionUse Case
GETRetrieve data from an APIGet user details from a service
POSTSend data to an APICreate a new record in a database
PUTUpdate existing dataUpdate a SharePoint list item
DELETERemove dataDelete a record from a system

2️⃣ Setting Up an HTTP Request in Power Automate

Step 1: Add the “HTTP” Action

  1. Open Power Automate
  2. Create a New Flow (Manual, Scheduled, or Automated)
  3. Add the “HTTP” action

Step 2: Configure the HTTP Request

  1. Select Method: GET, POST, PUT, or DELETE
  2. Enter the API URL
  3. Add Headers (if required, e.g., authentication)
  4. Add Query Parameters (if needed)
  5. Add Body Content (for POST and PUT requests)

Example 1: GET Request (Fetching Data from an API)

Use Case: Retrieve a list of users from a web API.

FieldValue
MethodGET
URLhttps://jsonplaceholder.typicode.com/users
HeadersContent-Type: application/json

Expected Response (JSON)

[
{
"id": 1,
"name": "John Doe",
"email": "john@example.com"
}
]

Next Step: Use the Parse JSON action to extract and use the data.


Example 2: POST Request (Sending Data to an API)

Use Case: Create a new task in an external system.

FieldValue
MethodPOST
URLhttps://api.example.com/tasks
HeadersContent-Type: application/json
Body
{
"title": "New Task",
"due_date": "2025-03-10"
}

Next Step: Check the response to confirm task creation.


Example 3: Using API with Authentication (Bearer Token)

Some APIs require authentication using OAuth 2.0 or API keys.

Steps to Use Bearer Token Authentication:

  1. Retrieve the API token (from API provider)
  2. Add it in the HeadersjsonCopyEdit{ "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" }

Example: Calling Microsoft Graph API

Method: GET
URL: https://graph.microsoft.com/v1.0/me
Headers:
Authorization: Bearer <access_token>
Content-Type: application/json

3️⃣ Handling API Responses in Power Automate

After making an API call, the response is usually in JSON format. Use:
“Parse JSON” Action – Extracts specific values from the response
“Condition” Action – Performs actions based on response values
“Apply to Each” Action – Loops through JSON arrays

Example: Extracting Name from API Response

  1. Add “Parse JSON” Action
  2. Use Sample JSON Schema { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string" } } }
  3. Use Dynamic Content to reference name

4️⃣ Best Practices for Using HTTP Requests in Power Automate

Use API Documentation – Always check API provider’s docs for required headers, methods, and body format.
Secure API Keys and Tokens – Store credentials securely using Azure Key Vault.
Handle API Rate Limits – Some APIs limit requests per minute/hour; avoid exceeding limits.
Use Retry Policies – Enable retries in case of temporary failures.
Test API Calls in Postman – Before adding to Power Automate, test in Postman or Graph Explorer.


Summary

HTTP Requests allow Power Automate to call external APIs and automate workflows.
Use GET, POST, PUT, and DELETE methods for retrieving, creating, updating, or deleting data.
Handle authentication using Bearer Tokens or API keys.
Use “Parse JSON” to extract data from API responses.
Follow best practices to optimize API calls and improve security.

Leave a Reply

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