This project demonstrates how to implement Custom APIs in Microsoft Dataverse for use with Power Platform. It includes a sample plugin implementation and a client application to show how to interact with the APIs.
This demo showcases two custom API implementations:
- GetAccountDetails - Retrieves account information along with related contacts
- CreateAccountWithContacts - Creates a new account and optionally creates related contacts
This class implements the plugin logic for both custom APIs:
- GetAccountDetails: Takes an Account ID as input and returns account details plus related contacts in JSON format
- CreateAccountWithContacts: Takes account data in JSON format and creates the account and related contacts
This class demonstrates how to call the custom APIs from a client application:
- Shows connection to Dataverse
- Demonstrates calling custom APIs using the Dataverse client
- Handles request/response formatting
- Build the project to generate the assembly DLL
- Register the assembly in your Dataverse environment using the Plugin Registration Tool
- Create a new step for each custom API and link to the
DataverseCustomApiclass
In your Power Platform environment, create two Custom API definitions:
- Display Name: Get Account Details
- Name: customapidemo_GetAccountDetails
- Unique Name: customapidemo.GetAccountDetails
- Binding Type: Global
- Execute Privilege: None (or appropriate security role)
- Input Parameters:
- Name: AccountId
- Type: String
- Required: Yes
- Output Parameters:
- Name: AccountDetails
- Type: String
- Display Name: Create Account with Contacts
- Name: customapidemo_CreateAccountWithContacts
- Unique Name: customapidemo.CreateAccountWithContacts
- Binding Type: Global
- Execute Privilege: None (or appropriate security role)
- Input Parameters:
- Name: AccountData
- Type: String
- Required: Yes
- Output Parameters:
- Name: AccountId
- Type: String
- Name: ContactIds
- Type: String
-
Setup:
- Deploy the plugin assembly
- Configure the Custom APIs in Power Platform
-
Test GetAccountDetails:
- Use the Dataverse Client to call the API with an existing account ID
- View the returned account information and related contacts
-
Test CreateAccountWithContacts:
- Use the Dataverse Client to create a new account with multiple contacts
- Show how the account and contacts are linked automatically
- Demonstrate the returned IDs
When presenting this demo, you can highlight:
-
Custom API Architecture:
- How custom APIs provide a consistent interface for Power Platform apps
- Advantages over traditional plugin approaches
-
Performance Considerations:
- Using FetchXML for optimized queries
- Error handling and tracing
-
Security Model:
- How permissions work with custom APIs
- Privilege requirements
-
Integration Points:
- How these APIs can be used from Power Apps, Power Automate, etc.
- External client application integration
-
Best Practices:
- Input validation
- Error handling
- JSON serialization/deserialization
- Transactional operations