Make Your First Custom Connector For Power Automate And Power Apps

Make Your First Custom Connector For Power Automate And Power Apps

There are currently over 500 connectors for Power Automate and Power Power Apps that allow us to interact with other web services. But what if the connector you want to use does not exist? Custom connectors make it possible to create our own connectors for any web service that has a REST API. We can define triggers and actions based on our own requirements and the best part is once built custom connectors are re-usable in any project

In this article I will show you how to make your first custom connector for Power Automate and Power Apps.

Table of Contents:
Introduction: The Currency Conversion Custom Connector
Obtain A Currency Scoop API
Review The Currency Scoop API Documentation
Create A New Custom Connector
Fill-In Custom Connector General Information
Apply Custom Connector Security Settings
Define An Action For A Custom Connector
Import Request From A Sample URL
Define Query Parameters For The Custom Connector
Add A Default Response To The Custom Connector
Save The Custom Connector
Transform The Custom Connector Response With C# Code (Optional)
Test The Custom Connector
Use The Custom Connector In Power Automate
Use The Custom Connector In Power Apps




Introduction: The Currency Conversion Custom Connector

In this tutorial we will make a customer connector to perform currency conversions with the Currency Scoop API. The custom connector will take in a base currency then convert it to a specified amount. It will available for use in Power Automate and PowerApps as shown below.




Obtain A Currency Scoop API Key

Currency Scoop is an independent service outside of the Power Platform. It provides an API with foreign exchange rates and other financial information.

To use the Currency Scoop API obtain an API key by creating a free account. API keys have a dual purpose: they act as both a unique identifier to track your usage of an API and as password to prevent unauthorized users from consuming an API.

Open the Currency Scoop website and sign-up for an account.




Input your email, full name and password. A link will be sent to verify your email address



Once your email address is verified login to your newly created account. You will see your API key on the Account Details page. Keep this tab open on your web browser until this tutorial is completed since we will require it several times.




Review The Currency Scoop API Documentation

When understanding how to use an API for the first time we should read its documentation. The Currency Scoop API Documentation tells what features are available, how to request information and show examples of what the API’s output (called a response) will look like.



We fill use the Convert feature of the API to perform a currency conversion. The documentation tells us we can use a URL like this…

https://api.currencyscoop.com/v1/convert?api_key=ac3edb3224562f500b240d33412345e0&from=USD&to=CAD&amount=1



…to return a response like this with the result. Give this a try for yourself by copying and pasting the URL above into a new web browser tab and substituting the sample API key with your own.




Create A New Custom Connector

Now that we’ve done the required pre-work its time to make our custom connector. Login to Power Automate, expand the data section on the left-navigation menu and select custom connectors. Then start a new custom connector and choose the create from blank option.




Fill-In Custom Connector General Information

Once the custom connector editor is open the first thing we must do is give our connector a name that describes which API it uses: Currency Scoop.



Then upload a connector icon of your choosing (optional) and fill in the general information tab with the following values from our sample URL.

:

FieldValue
SchemeHTTPS
Hostapi.currencyscoop.com
Base URL/



Here’s our sample URL for reference. Take a moment to understand where the values we used came from.

https://api.currencyscoop.com/v1/convert?api_key=ca7bde2665298f055a630b66192302f7&from=USD&to=CAD&amount=1




Apply Custom Connector Security Settings

Next we will setup authentication so our custom connector is allowed to access the Currency Scoop API.



Choose the API Key authentication type then fill-in the API section with these values:

FieldValue
Parameter labelapi_key
Parameter nameAPI Key
Parameter locationQuery



Once again, here’s our sample URL. Notice there are several pairings of [fieldname=value] found after the question mark (?) symbol. These are known as the query parameters. The API key is one of 4 parameters found in the URL.

https://api.currencyscoop.com/v1/convert?api_key=ca7bde2665298f055a630b66192302f7&from=USD&to=CAD&amount=1





Define An Action For A Custom Connector

Custom connectors can have one or more actions. In this tutorial on currency conversion connector will only have one action but we could extend it to have more later on. The Currency Scoop API Documentation outlines several other features beyond convert such as: latest, historical, timeseries, etc.

Go to the definition tab and select New Action.



Fill-in the General section with a summary, description and operation ID. The summary and description will be show in Power Automate to identify the action whereas Operation ID will be used in Power Apps. Operation ID must be a text string with no spaces.




Import Request From A Sample URL

The purpose of a request is to ask the API which information to retrieve. A typical request includes the feature we want to use and the parameters we want to filter the query by. Click Import from sample in the request section.



The Verb list shows a standard set of API request types. We want to use the API to query and retrieve data from Currency Scoop’s database so we choose the GET request. GET is the most popular type of API request along with POST which is used to write data to a database.



Copy and paste the sample URL we’ve been using into the URL field. Then click Import.

https://api.currencyscoop.com/v1/convert?api_key=ac3edb3224562f500b240d33412345e0&from=USD&to=CAD&amount=1




Define Query Parameters For The Custom Connector

When we import the sample URL its query parameters appear in the Request section. We must setup each of the parameters. Begin by deleting the api_key parameter. It is not needed because we already added it in the security section.



Edit the from parameter…



…by supplying a description and change the required setting to Yes.


Then edit the to parameter and the amount parameter and set them up in the same way.

q




Add A Default Response To The Custom Connector

In final section of the definition section we must describe the structure of the API response. A response is the data the API call returns and is usually in the form of a JSON object. Click on the add default response button.



Input a sample of the response JSON into the body section and click Import. The response can be obtained by copying and pasting our sample URL into the web browser.



The sample response should look like this:

{
   "meta": {
     "code": 200,
     "disclaimer": "Usage subject to terms: https://currencyscoop.com/terms"
   },
   "response": {
     "timestamp": 1628942872,
     "date": "2021-08-14",
     "from": "USD",
     "to": "CAD",
     "amount": 1,
     "value": 1.25154843
   }
 }




Save The Custom Connector

We’ve completed the definition for our convert action so now would be an excellent time to save our progress. To do this select Update Connector on the top menu.




Transform The Custom Connector Response With C# Code (Optional)

The code section can be used to reshape the response of the custom connector using C# code. This is an advanced topic and is not necessary to build our first connector so we will skip it. If you want to know more about what this screen does and how to use it check out my article: transform a custom connector response with C# code.




Test The Custom Connector

Before we can use the custom connector in Power Automate or Power Apps it must be tested. Click on the add icon to create a new connection.




A prompt appears to input the api_key because this is the authorization type we chose earlier on. Use the Currency Scoop API key you obtained here and click the create connection button.



Back on the Test screen click the Refresh icon and choose the newly create connector in the selected connection field. Then input the following parameters in the Convert section and press the Test Operation button.

  • from: USD
  • to: CAD
  • amount: 100





Once the test is completed scroll down to view the response. In the body section we can see the value of USD $100 is equal to $EUR 84.758344 at this moment in time.




Use The Custom Connector In Power Automate

Our custom connector is now ready to use in Power Automate so lets give it a try. Create a new instant flow with a manual trigger button. Then create a new custom action, choose the Currency Scoop action and select the Convert action.




Fill-in the Covert action parameters as shown below then Save the Flow and click Test. Choose to run a manual test.|



The flow will perform a test run and output the JSON response as values.




Use The Custom Connector In Power Apps

We can also test the custom connector in Power Apps. Create a new app from blank then add the Currency Scoop custom connector. Insert a label onto the screen and use this code in the Text property.

CurrencyScoop.Convert("USD", "EUR", 100).response.value



The value of the converted currency will be shown just like the image below.






Questions?

If you have any questions or feedback about Make Your First Custom Connector For Power Automate And Power Apps please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

29 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Lydia
Lydia
2 years ago

That was amazing, so simple and very useful!! Thank you Matthew, your instructions are always clear and helpful.

Last edited 2 years ago by Lydia
babu
babu
2 years ago

excellent,Thank you Sir

Joe
Joe
2 years ago

Any hints on how to fix a custom connector that works in preview but not when published? I made your navigation bar and it works fine during building, but when I access the app published, it just loads in the sample data instead of the data it shows in preview.

Joe
Joe
2 years ago

Hi, technically it’s for this post: https://www.matthewdevaney.com/power-apps-navigation-menu-component/ but the commenting is off on there. This post seemed the closest relevant one that I could raise the question as, in theory, it could happen to any custom connector.

Tony
Tony
2 years ago

Very nice writeup, with great detail. Many thanks for sharing!

nikita
nikita
2 years ago

hey i am nikita here , my question is i am using post method in request and after on testing the custom connector i am getting hello world in body response and the api is not actually hiting from the backend. can u please give me solution of my query ?

Nikita
Nikita
2 years ago

Sir i am using post method.

nikita
nikita
2 years ago

sir i am building another custom connector using post method but the api is not hiting from backend.

nikita
nikita
2 years ago

thank you!

Soyeb Malek
Soyeb Malek
2 years ago

Great article !
I have few queries, I created Custom Connector for fetching Teams User Presence/Status using MS Graph API.

Currently App is accessible without premium license (Trial License is also not activated).

Does Users need premium license to use this PowerApp ? I have around 600 Users so which license is best fit ?
Can we Skip/prevent Fix Connection for Custom Connector ? Because every few hours Fixing connection is not suitable for Users.

Dean
Dean
1 year ago

Thanks for another useful blog post. I’m implementing this in an pricing app but each user is asked to supply the api key when they use my app. Do you know if there is anyway around this because that is a deal breaker.

Dean
Dean
1 year ago
Reply to  Dean

I have added the api key as a query parameter with a default value instead of in the security settings. Although probably not as secure.it avoids the need to get every user in my organisation to add the API key.

Volker
Volker
1 year ago

Hi Matt,
just succesfully finished my first custom connector (accessing Jira via REST-API). Up to date only GET methods, but this tutorial surely acts as a good starting point for POST methods as well (at least I hope so ;-))
very much appreciated, thanks!

Raza
Raza
11 months ago

Here you manually define the currencies but what we can do if we to take input through canva app from user and base on input change the currencies?

Antony
Antony
6 months ago

Great blog site however in this guide are you API Parameter name and label the wrong way around?

Antony
Antony
6 months ago

Matt,

Apply Custom Connector Security Settings section in the image and table.

Hans Smeets
Hans Smeets
5 months ago

I cant get this to work, I keep getting a 401 error. Not sure what I am doing wrong, when i test it with just my api key in a url, it works fine. But when i test the connector I get:

{
 “meta”: {
  “code”: 401,
  “error_type”: “auth failed”,
  “error_detail”: “Missing or invalid api credentials. See https://currencybeacon.com/api-documentation for details.”
 },
 “response”: []
}