Build a custom connector for existing API

Completed

In this exercise, you'll create your first custom connector for an existing API called Contoso Invoicing.

Important

Use a test environment with Microsoft Dataverse provisioned. If you don't have a test environment, you can sign up for the Power Apps Community Plan.

Task: Review the API

To review the API, follow these steps:

  1. Go to Contoso Invoicing.

  2. Select the documentation link.

    Screenshot of an arrow pointing to the API documentation link.

  3. Review the available operations.

  4. Select to expand and review each operation.

  5. Close the documentation browser tab or window.

  6. Select the Open API definition link.

  7. The following image shows an example of the OpenAPI version of what was shown on the documentation page. Right-click and select Save as.

    Screenshot of an arrow pointing to the save as button.

  8. Save the file locally. You'll use this file later in the exercise.

  9. Close the definition browser tab or window.

  10. Select the API Key link.

  11. Copy and save your API key because you'll need it later.

    Screenshot of the API key for Contoso invoicing.

  12. Select Return to home.

  13. Select Download Logo.

  14. Save the logo image locally; you'll use it later.

Task: Create a new solution

To create a new solution, follow these steps:

  1. Go to Power Apps maker portal and make sure that you are in the correct environment.

  2. Select Solutions > + New solution.

  3. Enter Contoso invoicing for the Display name and select + New publisher.

    Screenshot showing the add new publisher button.

  4. Enter Contoso for Display name, Contoso for Name, contoso for Prefix, and then select Save.

  5. Select Contoso for Publisher, and then select Create. When you're working on a real project, it's best to create your own publisher.

    Screenshot of the create new Contoso Invoicing solution details.

  6. Don't navigate away from this page after selecting Create.

Task: Create a new connector

To create a new connector, follow these steps:

  1. Open the Contoso invoicing solution that you created.

  2. Select + New > Automation > Custom connector.

    Screenshot of an arrow pointing to create new custom connection.

  3. Enter Contoso invoicing for the Connector name and then select to Upload the image.

    Screenshot of an arrow pointing to the upload icon image button.

  4. Select the connector logo image that you downloaded in Task 1: Review the API.

  5. Enter #175497 for Icon background color.

  6. Enter Custom connector for Contoso Invoicing API for Description.

  7. Enter contosoinvoicingtest.azurewebsites.net for Host.

  8. Select Create connector.

    Screenshot of the create cutom connetor button.

  9. Don't navigate away from this page.

Task: Import the OpenAPI definition

To import the OpenAPI definition, follow these steps:

  1. Select the arrow next to Connector Name.

    Screenshot of an arrow pointing to the back button.

  2. Select the ellipsis (...) button of the connector and then select Update from OpenAPI file.

    Screenshot of an arrow pointing to the Update from open API file button.

  3. Select Import.

  4. Select the swagger.json file that you downloaded in Task 1: Review the API and then select Open.

  5. Select Continue.

  6. Fill in the host URL as contosoinvoicingtest.azurewebsites.net and then select Security.

    Screenshot of an arrow pointing to the Security tab.

  7. Notice that the fields are filled out from the imported file.

  8. Don't navigate away from this page.

Task: Review and adjust definitions

To review and adjust definitions, follow these steps:

  1. Select the Definition tab.

  2. Take a few minutes to review the operations that were imported.

  3. Notice the blue information circle next to GetInvoice.

  4. Select the GetInvoice operation.

    Screenshot showing the get invoice action.

  5. Notice that the operation indicates a missing Summary.

  6. Enter Get Invoice as the Summary to improve the usability.

    Screenshot of the Get invoice action summary.

  7. Notice the blue information circle next to the PayInvoice operation and that it indicates a missing Description.

  8. Enter Pay an invoice as the Description.

  9. Delete both NewInvoice operations because you won't use them.

    Screenshot showing the delete action button.

  10. Select the GetInvoiceSchema operation.

  11. Modify the Visibility option to internal so that people don't see it in their action list.

  12. Select Update connector.

    Screenshot of an arrow pointing to the Update connector button.

  13. Don't navigate away from this page.

Task: Test the connector

To test the connector, follow these steps:

  1. Select the Test tab.

  2. Select + New connection.

    Screenshot of an arrow pointing to the New connection button.

  3. Paste in the API Key that you saved in Task 1: Review the API and then select Create connection.

  4. Select the Refresh button.

    Screenshot of an arrow pointing to the Refresh button.

  5. Select ListInvoiceTypes > Test Operation.

    Screenshot of an arrow pointing to the Test operation button.

  6. You should see the invoice types data in the body area.

    Screenshot of the invoice types.

Task: Use custom connector in canvas app

In this task, you'll create a canvas application and use the custom connector you created to display a list of invoices.

  1. navigate to Power Apps maker portal and make sure that you are in the correct environment.

  2. Select Solutions and open the Contoso invoicing solution you created.

  3. Select + New and then select App > Canvas app.

    Screenshot showing the create new can application button.

  4. Enter Contoso invoicing app for App name, select Phone for Format, and then select Create.

  5. Select the Data tab, select + Add data, expand Connectors, and then select the Contoso invoicing custom connector you created.

    Screenshot showing the contoso invoicing custom connector.

  6. Select the + Add a connector.

  7. Paste in the API Key that you saved in Task 1: Review the API and then select Connect.

  8. Select Got it on the premium warning popup.

  9. Select the Tree view tab.

  10. Select + Insert and then select Vertical gallery.

    Screenshot showing the insert vertical gallery button.

  11. Select ContosoInvoicing for Data.

    Screenshot showing the select data dialog.

  12. Set the Items to the value below.

    ContosoInvoicing.ListInvoices().invoices
    

    Screenshot showing the gallery items value.

  13. Expand the gallery and select the Subtitle.

  14. Set the Text value of the Subtitle to ThisItem.amount.

  15. Expand the gallery and select the Title inside the gallery.

  16. Set the Text value of the Title to ThisItem.accountName.

    Screenshot showing the title text value.

  17. The gallery should now look like the image below.

    Screenshot showing the gallery.