Friday, December 30, 2022

Create a Custom API in PowerApps and Use it

 Step-by-step process to create a custom API 

- Use Custom APIs to create our own APIs in Dataverse. We can consolidate one or more operations into a Custom API that developers can call in their code or from Power Automate.

- We can use Custom API as business events to enable creating new integration capabilities such as exposing a new type of trigger event in the Microsoft Dataverse connector.

Custom APIs are an alternative to Custom process actions. Custom process actions provide a no-code way to include custom messages but have some limitations for developers. Custom APIs provide capabilities specifically for developers to define their logic in code with more options.

Let's begin:

Note: 

1. When creating a Custom API, we must use a solution.
2. 
Many fields related to creating Custom API cannot be changed once created. We should carefully plan the design of the Custom API before we start. If later decide that we need to change things once created the Custom API, we may need to delete the existing record and re-create the Custom API. Refer to Custom API Tables to review the column which can not be changed.

Step 1: Create a Custom API Record:

1. Open the solution, click New > More > Other > Custom API from the drop-down.
2. 
Edit the fields to set the properties of your Custom API. We cannot set values for Plug-in Type unless you have already created the plug-in. You can change this later.

3. Click Save. See the below screen for reference 


Step 2: Create Request Parameter Record
  1. In the solution, click New > More > Other > Custom API Request Parameter from the drop-down.

  2. Edit the fields to set the properties of your Custom API Request Parameter. 

  3. Click Save. The form should look something like this:



Step 3: Create a Response parameter record:
  1. In the solution, click New > More > Other > Custom API Response Property from the drop-down.

  2. Edit the fields to set the properties of the Custom API Response Property.

  3. Click Save. The form should look something like this:




Step 4: Update the Custom API Plugin Type
2. Once assembly is registered, We need to set the Plugin Type value for the Custom API which we created. This is a lookup property, so we just need to find the Plug-in Type that represents the type created when we registered the assembly.


Once we have set the Plugin Type  the Custom API looks something similar to this:

Step 5: Test the Custom API using Postman Tool
   To verify whether the correct results are returned.
Happy Learning...!!!