🔹 Connecting to APIs using Custom Connectors in Power Apps – A Complete Guide
📌 Introduction
Custom Connectors in Power Apps and Power Automate allow you to integrate external APIs and interact with third-party services that do not have prebuilt connectors. By using Custom Connectors, you can extend Power Apps’ functionality to fetch, post, update, and delete data from external sources.
🔹 Step 1: Prerequisites
Before creating a Custom Connector, ensure the following:
✅ You have access to Power Apps and Power Automate.
✅ The API you want to connect to supports REST (HTTP) requests.
✅ You have the API endpoint URL and necessary authentication details (API Key, OAuth, etc.).
✅ The API provides a valid JSON response.
✅ (Optional) Postman for testing API endpoints.
🔹 Step 2: Understanding API Basics
A. Types of API Requests
Request Type | Description | Example |
---|---|---|
GET | Fetch data from an API | Retrieve user details |
POST | Send data to an API | Create a new record |
PUT | Update existing data | Modify a record |
DELETE | Remove data from an API | Delete a record |
B. Example API Endpoint (JSON Placeholder API)
A sample GET request to fetch user data:
https://jsonplaceholder.typicode.com/users
Response:
[
{
"id": 1,
"name": "John Doe",
"email": "johndoe@example.com"
}
]
🔹 Step 3: Creating a Custom Connector in Power Apps
A. Open the Custom Connector Setup
- Go to Power Apps → Power Apps.
- Click “Dataverse” (left panel) → “Custom Connectors”.
- Click “New custom connector” → Choose “Create from blank”.
- Enter a Connector Name (e.g.,
MyAPIConnector
).
B. Define API General Information
- Scheme: Select HTTPS.
- Host: Enter the API hostname (e.g.,
jsonplaceholder.typicode.com
). - Base URL: Provide the API base path (e.g.,
/users
).
C. Set Authentication Type
Select an authentication method:
🔹 No Authentication – Public APIs (e.g., JSONPlaceholder).
🔹 API Key – Enter API Key header value (e.g., Authorization: Bearer YOUR_API_KEY
).
🔹 OAuth 2.0 – For APIs like Microsoft Graph, Google APIs.
🔹 Basic Authentication – Username and password-based login.
🔹 Step 4: Defining API Actions
A. Adding a GET Request
- Click “Definition” → “New Action”.
- Summary: Enter a description (e.g., “Get User List”).
- Operation ID: Enter a unique identifier (e.g.,
GetUsers
). - Click “Request” → “Import from Sample”.
- Select GET and enter the URL:
https://jsonplaceholder.typicode.com/users
- Click Import → The API will be added to the request section.
B. Defining Response Schema
- Click “Response” → “Add Default Response”.
- Paste the JSON response sample (from Step 2).
- Power Apps will generate the response schema automatically.
🔹 Step 5: Testing the Custom Connector
- Click “Test” → Choose an action (
GetUsers
). - Click “Test Operation”.
- If the request is successful, you’ll see API data returned in JSON format.
🔹 Step 6: Using the Custom Connector in Power Apps
- Open Power Apps Studio.
- Click “Data” → “Add Data”.
- Search for the newly created Custom Connector and select it.
- Insert a Gallery (
Insert → Gallery → Vertical
). - Set its Items property to:
MyAPIConnector.GetUsers()
- Map API fields to controls (e.g.,
ThisItem.name
).
🔹 Step 7: Performing CRUD Operations
A. Adding a New Record (POST Request)
- Create a new action in the Custom Connector.
- Select POST and enter the URL:
https://jsonplaceholder.typicode.com/users
- Define request parameters (e.g.,
name
,email
). - Use the following Power Apps formula to create a record:
MyAPIConnector.CreateUser({name: txtName.Text, email: txtEmail.Text})
- Click Submit to send data to the API.
B. Updating an Existing Record (PUT Request)
- Create a PUT action in the Custom Connector.
- Use this Power Apps formula:
MyAPIConnector.UpdateUser(Gallery1.Selected.id, {name: txtName.Text, email: txtEmail.Text})
C. Deleting a Record (DELETE Request)
- Create a DELETE action in the Custom Connector.
- Use the following Power Apps formula:
MyAPIConnector.DeleteUser(Gallery1.Selected.id)
🚀 CRUD operations enable full API integration!
🔹 Step 8: Automating API Calls with Power Automate
- Go to Power Automate → Create a new flow.
- Select Trigger (e.g., “When a button is clicked”).
- Choose “Custom Connector” as an action.
- Select the desired API request (e.g.,
GetUsers
). - Add additional steps like notifications, data storage, etc..
- Save & test the flow.
🔹 Step 9: Best Practices for Using Custom Connectors
✅ Use API Authentication – Prefer OAuth 2.0 for security.
✅ Optimize API Calls – Fetch only necessary fields using query parameters.
✅ Handle Errors – Use IfError()
to catch API failures.
✅ Cache Data – Store frequently used API results in Collections.
✅ Avoid Overloading APIs – Use pagination for large datasets.
🔹 Troubleshooting Common Issues
Issue | Solution |
---|---|
Connector not returning data | Check API Key, Headers, and authentication settings. |
Slow API response | Use pagination and avoid unnecessary API calls. |
Unauthorized Error (401) | Verify API authentication method (OAuth, API Key). |
Power Apps not displaying API data | Ensure API response format matches Power Apps expectations. |
🔹 Conclusion
Using Custom Connectors in Power Apps allows you to integrate external APIs, fetch and update external data, and extend app functionality beyond built-in connectors. 🚀
💡 For better scalability, consider using APIs with Dataverse, SQL Server, or SharePoint.