Parsing JSON from APIs or HTTP calls in Power Automate
Parsing JSON from APIs or HTTP Calls in Power Automate
When working with APIs, webhooks, or external services in Power Automate, the response is often in JSON format. To access that data reliably, you need to understand parsing JSON from APIs or HTTP calls in Power Automate.
This guide walks you through decoding complex JSON structures, extracting the data you need, and avoiding common errors.
📑 Table of Contents
- Why Parsing JSON Matters in Power Automate
- JSON Response Example
- Step-by-Step: How to Parse JSON from an HTTP Call
- Real-World Use Cases
- Expressions and Tips for Accessing JSON Data
- Best Practices
- Common Mistakes to Avoid
- Summary
🌐 Why Parsing JSON Matters in Power Automate
Most REST APIs and third-party services return data in JavaScript Object Notation (JSON) — a structured format of keys and values. You must parse this JSON to:
- Access specific properties in subsequent actions
- Use dynamic content like names, IDs, or URLs
- Loop through arrays in the response
- Prevent null reference or “InvalidTemplate” errors
Without parsing the JSON properly, Power Automate cannot “understand” the structure of the response.
🧾 JSON Response Example
Here’s a typical JSON response from an HTTP action:
{
"user": {
"id": "abc123",
"name": "Jane Doe",
"email": "jane@example.com"
},
"roles": ["Admin", "Editor"],
"active": true
}
To extract the user’s email, you’d need to parse the JSON correctly and use this path:
body('Parse_JSON')?['user']?['email']
🧰 Step-by-Step: How to Parse JSON from an HTTP Call
🔹 Step 1: Use the “HTTP” Action
- Add an HTTP action to make a GET or POST request to the API.
- Example: GET
https://api.example.com/users/1
🔹 Step 2: Add “Parse JSON” Action
- Next, add the Parse JSON action.
- In Content, select
Body
from the HTTP response. - Click Generate from sample.
🔹 Step 3: Paste Sample JSON
- Copy a real response from the API and paste it.
- Power Automate will generate a schema automatically.
🔹 Step 4: Access Parsed Fields
- Once parsed, the fields appear as dynamic content in the next steps.
- Use expressions if needed:
body('Parse_JSON')?['user']?['name']
💼 Real-World Use Cases
Scenario | API | Use |
---|---|---|
Get weather updates | OpenWeatherMap | Show temperature in Teams |
Retrieve user info | Microsoft Graph API | Auto-fill form with user data |
Fetch order details | Shopify API | Send invoice via email |
Pull ticket info | Zendesk | Notify support agents |
🧪 Expressions and Accessing JSON Data
Task | Expression | Description |
---|---|---|
Get nested value | body('Parse_JSON')?['user']?['email'] |
Access nested property |
Get first item in array | body('Parse_JSON')?['roles'][0] |
First role in list |
Check value exists | if(empty(body('Parse_JSON')?['user']?['name']), 'N/A', body('Parse_JSON')?['user']?['name']) |
Prevent null error |
Loop through array | Use Apply to each on body('Parse_JSON')?['roles'] |
Loop logic |
✅ Best Practices for Parsing JSON in Power Automate
- ✅ Always test the API manually and get a real sample of the response
- ✅ Use Generate from sample in “Parse JSON” to auto-generate schemas
- ✅ Simplify by using only necessary fields in your schema
- ✅ Wrap JSON access in
coalesce()
orempty()
to avoid null errors - ✅ Store parsed data in variables if reused multiple times
- ✅ Use Apply to each for arrays and collections
⚠️ Common Mistakes to Avoid
Mistake | Fix |
---|---|
Using raw body() instead of Parse JSON |
Always use the Parse JSON action to avoid schema errors |
Accessing fields that don’t exist | Use hasProperty() or check empty() |
Wrong array index | Validate structure first with Peek Code |
Assuming static structure | APIs can return optional or null fields – validate first |
Hardcoding JSON structure | Use dynamic parsing for flexible flows |
📘 Summary: Mastering Parsing JSON from APIs or HTTP Calls in Power Automate
Parsing JSON from APIs or HTTP calls in Power Automate unlocks powerful integrations by allowing you to extract, transform, and use dynamic data.
- Use the Parse JSON action to decode the structure
- Extract fields with dynamic content or expressions
- Safeguard your flow with error handling
- Apply best practices for scalability and reliability
Would you like a working sample flow exported in JSON format? Or should I help you write a Parse JSON schema for a specific API you’re working with?
Let me know — happy to assist!