In this blog post, we will explore how to retrieve metadata definitions for Microsoft Dataverse tables using Web APIs. Before we begin, ensure you subscribe to CRM Crate to remain informed about the latest developments in the Power Platform field.

Dynamics 365 Customer Engagement (CE) Web API and Microsoft Power Apps Web API both serve as robust RESTful interfaces for interacting with data and services, but they cater to slightly different needs within the Microsoft ecosystem. The Dynamics 365 CE Web API is tailored for operations within the Dynamics 365 suite, allowing developers to perform CRUD operations, execute complex queries, and access metadata specifically for modules like Sales and Customer Service. On the other hand, the Power Apps Web API, built on the Microsoft Dataverse, offers a more generalized approach suitable for a wider range of applications, including those created in Power Apps and Power Automate. Both APIs support secure OAuth 2.0 authentication, enabling seamless integration and automation across various platforms. Whether you’re looking to extend the capabilities of Dynamics 365 or build custom solutions with Power Apps, these APIs provide the necessary tools to streamline data management and enhance functionality.
Using the standard Web APIs for fetching Dataverse Table definitions
Dataverse is built to help you quickly and easily create a data model for your application. You usually don’t need to worry about the details of metadata, but if you want to understand more about how Dataverse apps work or what they can do, learning about metadata can be helpful.
Metadata is data about data. Dataverse is flexible because you can easily change the data definitions it uses. In Dataverse, metadata is a set of tables that describe the kinds of data stored. This metadata controls the types of records you can create and the actions you can take with them. When you use tools to create or edit tables, columns, and relationships, you are changing this metadata.
Different tools that people use to interact with your data rely on this table metadata and adjust when you customize it. These tools also need other data to decide what visual elements to show, what custom logic to apply, and how to manage security. This system data is stored in tables too, but these tables can’t be customized.
You can perform any table and column definition (metadata) operations with the Web API & using the .NET SDK (Web API Metadata Entity Type Reference).
There are four entity set paths available for performing operations with definition entities, as outlined below.
Fetching Entity Definitions
Entity Definitions
Web API – [Organization URI]/api/data/v9.2/EntityDefinitions
.NET SDK – EntityMetadata EntityType
Below is the sample response of the above Web API.

Below is the sample .NET SDK code for fetching Entity / Table Metadata.
// Create the request object
var request = new RetrieveEntityRequest
{
LogicalName = "account",
EntityFilters = EntityFilters.All,
RetrieveAsIfPublished = true
};
// Send the request to the organization service
var response = (RetrieveEntityResponse)orgService.Execute(request);
// Get the entity metadata from the response
var entityMetadata = response.EntityMetadata;
// Use the entity metadata
Console.WriteLine($"Entity Name: {entityMetadata.DisplayName.UserLocalizedLabel.Label}");
Console.WriteLine($"Number of Attributes: {entityMetadata.Attributes.Length}");
Console.WriteLine($@"Number of Relationships: {entityMetadata.ManyToManyRelationships.Length
entityMetadata.ManyToOneRelationships.Length
entityMetadata.OneToManyRelationships.Length}");
var ownerAttribute = entityMetadata.Attributes.Where(a => a.LogicalName.Equals("ownerid")).FirstOrDefault();
Fetching Relationship Definitions
Relationship Definitions
Web API – [Organization URI]/api/data/v9.2/RelationshipDefinitions
.NET SDK – ManyToManyRelationshipMetadata EntityType and OneToManyRelationshipMetadata EntityType as both inherit from RelationshipMetadataBase EntityType
Below is the sample response of the above Web API.

Fetching Global Option Set Definitions
Global Optionset Definitions
Web API – [Organization URI]/api/data/v9.2/GlobalOptionSetDefinitions
.NET SDK – BooleanOptionSetMetadata EntityType and OptionSetMetadata EntityType as both inherit from OptionSetMetadata EntityType
Below is the sample response of the above Web API.

Fetching Managed Property Definitions
Managed Property Definitions
Web API – [Organization URI]/api/data/v9.2/ManagedPropertyDefinitions
.NET SDK – Not available as this is only for internal use
Below is the sample response of the above Web API.

In conclusion, leveraging Web APIs for retrieving Dataverse table metadata definitions offers a streamlined approach to accessing and managing data structures, enhancing efficiency and facilitating seamless integration within data management workflows.
… [Trackback]
[…] Read More: crmcrate.com/web-api/retrieving-dataverse-table-metadata-definitions-via-web-apis/ […]