Skip to content

Repository files navigation

Power Platform/Dataverse Custom API Demo

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.

Overview

This demo showcases two custom API implementations:

  1. GetAccountDetails - Retrieves account information along with related contacts
  2. CreateAccountWithContacts - Creates a new account and optionally creates related contacts

Implementation Details

DataverseCustomApi.cs

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

DataverseClient.cs

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

How to Deploy

1. Register the Plugin Assembly

  1. Build the project to generate the assembly DLL
  2. Register the assembly in your Dataverse environment using the Plugin Registration Tool
  3. Create a new step for each custom API and link to the DataverseCustomApi class

2. Configure Power Platform Custom APIs

In your Power Platform environment, create two Custom API definitions:

GetAccountDetails API

  • 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

CreateAccountWithContacts API

  • 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

Demo Walkthrough

  1. Setup:

    • Deploy the plugin assembly
    • Configure the Custom APIs in Power Platform
  2. Test GetAccountDetails:

    • Use the Dataverse Client to call the API with an existing account ID
    • View the returned account information and related contacts
  3. 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

Talking Points

When presenting this demo, you can highlight:

  1. Custom API Architecture:

    • How custom APIs provide a consistent interface for Power Platform apps
    • Advantages over traditional plugin approaches
  2. Performance Considerations:

    • Using FetchXML for optimized queries
    • Error handling and tracing
  3. Security Model:

    • How permissions work with custom APIs
    • Privilege requirements
  4. Integration Points:

    • How these APIs can be used from Power Apps, Power Automate, etc.
    • External client application integration
  5. Best Practices:

    • Input validation
    • Error handling
    • JSON serialization/deserialization
    • Transactional operations

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages