Create Custom API to Read Contact in Dynamics 365 with XrmToolBox
Introduction:
This blog explores building custom APIs within Power Apps by leveraging plugins. Custom APIs empower developers to expose specific functionalities of Dynamics 365, enabling seamless integration with external systems and services.
Scenario: We will create a Custom API of Entity Binding type with a plugin tailored to reading contact records in Dynamics 365. Following this, we'll set up and associate this Custom API with the registered plugin, and illustrate how to invoke the API using either the XrmToolBox custom API tester or Power Automate Flow.
Refer to this video for a detailed implementation guide for Developing, Configuring and Invoking Custom API
Custom API Binding Types
In Power Apps, custom APIs offer a flexible way to extend the capabilities of your data platform by defining custom messages that can be invoked from various sources. These messages can interact with data or perform custom logic. A key aspect of custom APIs is the concept of binding types, which determine how the API interacts with entities in your Dataverse environment.
Here's a breakdown of the three available binding types and we will focus on the implementation for the Global type:
Global:
- Description: This type is most versatile as it doesn't have a specific association with any entity. It's suitable for operations that don't directly work with entity records.
- Use Cases:
- Performing calculations or manipulations on data that doesn't reside in a particular entity.
- Triggering workflows or custom actions that aren't tied to an entity.
- Integrating with external services or systems that don't map directly to Dataverse entities.
Entity:
- Description: This type binds the custom API to a specific entity (table) in Dataverse. It's designed for operations that accept a single record of that entity as input or return information about a single record.
- Use Cases:
- Performing operations on a single entity record, such as creating, updating, or deleting a record.
- Validating data against entity-specific rules before processing it further.
- Retrieving details about a specific entity record.
EntityCollection:
- Description: This type also binds to a specific entity, but it's used for operations that involve collections of records from that entity. It can accept a collection of entity records as input or return a collection of records as output.
- Use Cases:
- Performing bulk operations on multiple entity records, such as creating, updating, or deleting multiple records at once.
- Querying and retrieving a collection of entity records based on specific criteria.
Prerequisites
Before starting on the development of the custom API using a plugin, ensure you possess the necessary tools, licenses, and knowledge outlined below.
- Power Apps License
- XrmToolBox with Custom API Manager and Custom API Tester installed
- Power Automate License (Optional to Invoke)
- Plugin/C# Development Knowledge
- Visual Studio (with .Net Framework 4.6.2 for plugin development)
- Plugin Registration Tool
Below is a snapshot from the XrmToolBox Custom API Manager, showcasing an Entity type custom API designed for reading a contact, featuring input and output response properties.
Creating a Custom API in Custom API Manager
Plugin Code-
No comments:
Post a Comment