Guidance on how to use REST Countries Power Platform Connector

Recently I have published a Power Platform Connector as an Independent Publisher which allows us to Get Countries of the world using  REST countries API. Special thanks to Kunj Sangani and Parth Patel for your help on this 🙂

You can find the connector details at this link.

This connector uses the REST Countries API which provides us details of the countries in the world along with so much information like country name, region, sub-region, time zone, currency, currency symbol, languages, countries capital, the start of the week, continent, population, png of the country flag from public CDN, etc..(I am putting a screenshot of India’s data below for quick reference). This information can be useful to use in many scenarios where we create our own list/table to store this or hardcode in the dropdown… Using this connector will help fill the Country dropdown and also use the relevant country information in our business case.

The endpoint which is called –  https://restcountries.com/v3.1/all

Screenshot of the connector

 

Data about India from the endpoint to give an idea about different attribute available for each country.

Now let us see how to use this connector in Powerapps to create a Combobox or dropdown.

Step – Add the REST Countries connector as Datasource to our PowerApps.

Step – On your targeted screen, Add a combo box and select REST countries as data source.

In this connector, we only have one endpoint which is available and named ALL.

So now for the Combo Box, select the Items properties and add the below code and if you expand ALL function to see the data returned you will see it has returned Data type Table

'RESTCountries(IndependentPublisher)'.ALL()

So it is returning us a list of all the countries, Ideally, we would have to choose a field now to show in the combo box, but if you noticed the JSON object returned for each country does not return name as a string but as another object. Below is the reference for Country India.

So if you choose the field, we won’t able to find name as field to select.

Let us tweak the formula of Items properties to Add columns from the name JSON object to use as in our fields.

AddColumns('RESTCountries(IndependentPublisher)'.ALL(),"CountryName", name.common, "OfficialName",name.official)

We can see now that the CountryName and OfficialName came as attribute on root object.

Now let us go to the Fields and Select CountryName

Run the app now and we can see the Combobox is populating all the countries’ names, I have enabled search so it allows us to search items by typing the country name.

From here it is a pretty common scenario where we can use Combobox1.Selected  to retrieve the whole country object and use its attributes by drilling down…

Add an Image control to the screen and set its image property to below/

ComboBox1.Selected.flags.png

Run the app and select some country, we will see the flag of the country displayed

Similar way you can access all the properties as returned by the REST API from https://restcountries.com/v3.1/all

Usage of the connector in PowerAutomate is also similar, we just add the connector inflow and it will return us JSON object in response, Parse the JSON, and access the targeted attributes/properties.

Hope this connector helps you avoid storing local countries’ lists and also be useful to get the country’s information in your business case..!!

Happy low coding..!!

(Visited 340 times, 1 visits today)