dotnet-podcasts/docs/demos/powerapps/README.md

47 lines
2.4 KiB
Markdown
Raw Normal View History

2022-09-17 08:01:40 +08:00
# Connecting APIs to the Microsoft Power Platform
2022-09-14 11:18:25 +08:00
2022-09-20 00:01:12 +08:00
Before getting started, ensure that you have successfully imported the Approval App into your Power Apps environment. For more information, see this [tutorial](https://github.com/user/repo/src/PowerApps/README.md).
2022-09-14 11:18:25 +08:00
# Create a custom connector
2022-09-17 07:53:47 +08:00
[Custom connectors](https://docs.microsoft.com/en-us/connectors/custom-connectors/) are a powerful way to connect to any existing API from within Power Apps. A custom connector is a wrapper around a REST API that allows the Power Platform to communicate with your REST API.
2022-09-14 11:18:25 +08:00
2022-09-20 00:01:12 +08:00
From within Azure API Management, you can easily create such custom connectors. [Follow the tutorial](https://docs.microsoft.com/en-us/azure/api-management/export-api-power-platform) on how to export your API from API Management.
2022-09-14 11:18:25 +08:00
# Connect your Podcast Approval application with your web API
2022-09-20 00:01:12 +08:00
Open the Podcast Approval App within Power Apps:
2022-09-17 07:53:47 +08:00
2022-09-14 11:18:25 +08:00
![editpowerapp](./assets/editpowerapp.jpg)
2022-09-20 00:01:12 +08:00
There will be some error messages within the Power App:
2022-09-17 07:53:47 +08:00
2022-09-14 11:18:25 +08:00
![powerapp](./assets/powerapp.jpg)
2022-09-20 00:01:12 +08:00
To fix these, add the custom connector to the Approval App via the data tab:
2022-09-17 07:53:47 +08:00
2022-09-14 11:18:25 +08:00
![customconnector](./assets/customconnector.jpg)
2022-09-17 08:13:02 +08:00
2022-09-20 00:01:12 +08:00
*Note: Search for the name of your custom connector created via API Management. If you have enabled [subscriptions within API Management](https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions), you need to provide an API key to the consumer to access the API. Please read this article to find out how to [access subscription keys within API Management](https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-create-subscriptions#create-a-new-subscription).*
2022-09-14 11:18:25 +08:00
2022-09-17 07:53:47 +08:00
# Modify your Power App
2022-09-14 11:18:25 +08:00
2022-09-20 00:01:12 +08:00
Next, update your Power App via the Power Editor.
2022-09-14 11:18:25 +08:00
## OnStart
2022-09-20 00:01:12 +08:00
Every time the Power App starts up, we want to make an API call getting us the information about current requests. For this, change the [OnStart behavior](https://docs.microsoft.com/en-us/power-platform/power-fx/reference/object-app) and modify **'.NETPodcasts'.GetUserSubmittedFeeds()**:
2022-09-14 11:18:25 +08:00
Additional Information:
2022-09-17 07:53:47 +08:00
- **'.NETPodcasts'** is referencing the name of the custom connector
2022-09-20 00:01:12 +08:00
- **GetUserSubmittedFeeds()** is referencing the API's operation name
2022-09-17 07:53:47 +08:00
![onstart](./assets/onstart.jpg)
2022-09-14 11:18:25 +08:00
# Refresh Button
2022-09-20 00:01:12 +08:00
Next, update the refresh button properties by modifiying **'.NETPodcasts'.GetUserSubmittedFeeds()**:
2022-09-14 11:18:25 +08:00
![refreshbutton](./assets/refreshbutton.jpg)