Background
Power Platform is great in automation, but its true potential unlocks when you can connect it to non-standard data sources. This is where custom connectors come in, acting as bridges between Power Platform and external APIs.
In this guide I will show you how to create custom connectors:
Steps to creating Custom Connectors for Power Platform
Building the Connector in Power Automate:
-
Launch Power Automate: Sign in and navigate to the “Solutions” section. Create a new solution or open an existing one.
-
Add a Custom Connector: Within the solution, expand the “New” menu and select “Automation” > “Custom connector.”
-
Define Connection Details: Choose “Create from blank” and provide a descriptive name for your connector.
-
Import API Definition (Optional): If the API offers an OpenAPI (Swagger) definition file (.json or .yaml), you can import it to automatically populate actions and data models. Otherwise, you’ll need to define them manually.
-
Define Actions: Here’s where the magic happens! Create actions representing the functionalities you want to expose in Power Apps. Each action should have a clear name, a concise description, and well-defined parameters (inputs) and outputs.
- Parameters: Specify the data types (text, number, etc.) required for each action.
- Outputs: Define the structure of the data returned by the action (often matching the API’s response format).
Example Action
Let’s say you’re building a connector for a weather API. You might create an action named “GetWeather” that accepts a “city” parameter (text) and returns an output containing “temperature,” “humidity,” and “weather description” (all text).
-
Configure Authentication: Specify the authentication method your chosen API requires. This could involve API keys, OAuth, or other methods.
-
Test and Validate: The “Test” tab allows you to send test requests with sample data to ensure your connector functions as expected. Refine your definitions until the tests pass successfully.
-
Save and Publish: Once everything is working smoothly, save your connector and then publish it to make it available in your environment.
Using the Custom Connector in Power Apps
-
Create a Power App: Build a new Power App or open an existing one.
-
Connect to the Custom Connector: Navigate to the “Data” pane and select “Add data.” Choose the “Connectors” tab and locate your custom connector by name. Click on it to establish a connection.
-
Utilize the Connector Actions: Within your Power App formulas and expressions, you can now leverage the actions you defined in your custom connector.
Example Usage
In your weather app, you could use the “GetWeather” action within a formula to display the current temperature and weather description for a user-entered city.