Creating a Power Apps Custom Connector from API Documentation for Power BI

A short guide to making a Power Apps/Automate custom connector for Power BI from scratch

Dhyanendra Singh Rathore
6 min readNov 14, 2021
Photo by Elf-Moondance from Pixabay

Custom connectors extend the capabilities of Power Apps, Power Automate, and Azure Logic Apps. There are multiple ways to create a custom connector, and unarguably the most straightforward way is to use an OpenAPI definition file or a Postman collection. But what if there's no OpenAPI definition or Postman collection available? Or simply put, you want to build a custom connector customized to the bone solely to support your needs.

This article will build a Power Apps custom connector from scratch with the help of resource API documentation. We'll create a connector for Power BI REST APIs for a handful of actions. However, the concept and steps should apply to every REST API out there.

Caution: Microsoft Azure, Power Apps, and Power BI are paid services, and following this article can cause financial liability to you or your organization.

Please read our terms of use before proceeding with this article: https://dhyanintech.medium.com/disclaimer-disclosure-terms-of-use-fb3bfbd1e0e5

Prerequisites

We recommend going through the following article to set up an Azure AD app with the proper API permissions, configure the custom connector security, test the connection, and how to build a flow to test the new connector actions. This article will only focus on the Definition of the custom connector.

Custom Connector

Sign in to Power Apps or Power Automate and create a new custom connector from blank. Follow these steps:

  1. In the navigation pane, select Data > Custom connectors.
  2. Select New custom connector, then choose Create from blank.
  3. Enter a name for the custom connector, then Continue.
Power Apps: Creating a custom connector from blank (Image by author)

Fill in the general details and security configuration as discussed in the previously mentioned article and jump to the Definition tab; this is where all the Actions are :) On the Definition page, the left area displays the actions, references, and policies for the connector.

Add an Action — Fill up the General Details

We'll be defining the actions for the connector from the API documentation. To demonstrate the process, we will add one action in the connector. Open the API documentation in the new tab, and let's add the action (Get Groups).

  1. On the Definitions page, Choose New action.

2. The General area displays information about the action. Add a summary, description, and operation ID for this action. The summary is what your users will see as the name of the action, the description is shown as an info icon for additional details, and the operation ID is the connector's unique identifier for the action. You can define a consistent convention for all your actions. It's good to provide details about the action, scope, and link to the API documentation in the description. For example:

Power Apps: Creating a new action (Image by author)

Visibility property for operations and parameters has the following options:

  • none: displayed normally in the logic app or flow
  • advanced: hidden under another menu
  • internal: hidden from the user
  • important: always shown to the user first

Define the HTTP Request

3. The Request area defines the information based on the HTTP request for the action. Choose Import from sample.

4. Specify the Verb (HTTP method) and URL to connect to the API (and the request body, if applicable), then select Import.

Power Apps: Define the request for the action (Image by author)

5. Once you've defined the URL in the connector action, URI parameters appear under either Path or Query as applicable. The URI Parameters section in the API documentation contains the details about these parameters, e.g., name, whether they form the path or query, if they are mandatory, expected data type, and a brief description of their purpose.

6. We need to ensure that these parameters' data types and mandates match as expected by the API to avoid any potential errors during action execution. Click the options () next to $top and select Edit.

By default, all path parameters are mandatory, and all query parameters are optional.

All parameters are considered to be strings and must be corrected manually.

Power Apps: Edit query parameters (Image by author)

7. Change the Type to 'integer' and Format to 'int32'. You can also define a default value and edit other properties of the parameters. Keep an eye on the Validation section at the bottom, and select Back.

Power Apps: Update query parameters (Image by author)

Specify the HTTP Response

8. The Response area displays information based on the HTTP response for the action. Choose Add default response. Copy the sample response from the API documentation, paste it under the Body and select Import.

Power Apps: Add default response for the action (Image by author)

9. You can view the added response by selecting the default response under the Response section. Notice that you've multiple parameters available in the Body (from the sample response you've pasted earlier). These parameters will be available in the power app and flow to select and take further actions like filtering or use in formulas and calculations. Repeat points 6 & 7 to ensure they have the correct data type specified in the API documentation.

At the time of writing, the Power Apps custom connector does not support GUID and other complex data types for parameters.

Power Apps: Reviewing response body of the action (Image by author)

10. Select Create connector at the top, wait for page refresh to finish, and proceed to test the connector (discussed here).

Power Apps: Test the action with a flow (Image by author)

Pro-tip: If the API documentation is missing a sample request or response body, you can create a sample with empty values; however, the keys must be correct. For example

{
"name":"",
"targetModelId":"",
"targetWorkspaceId":""
}

That brings this article to an end. We've created and tested a brand new Power Apps custom connector from scratch.

Next Steps

We do occasionally run into problems. We’ve got a comprehensive article to cover the frequent errors and issues. Take a look.

Like this post? Connect with Dhyan

Let’s be friends! You can find me on LinkedIn or join me on Medium.

--

--