Blogs

Lookup CRM Metadata Using API in Postman

, February 21, 20250 View

In today’s fast-paced digital world, understanding and leveraging metadata is key to building robust, data-driven applications. Working with CRM systems, having quick access to metadata especially for lookup fields can significantly streamline customization and integration efforts. In this blog, we’ll walk you through the process of fetching CRM metadata using API calls in Postman, with a special focus on retrieving the names of ID columns using the Prefer: odata.include-annotations=”*” header. 

Why Fetch CRM Metadata?

CRM metadata provides valuable information about the structure of your data such as entity definitions, attributes, and relationships. When working with lookup fields (which link records across different entities), knowing the exact naming conventions and associated annotations can help you:

  • Ensure Consistency: Validate that your custom integrations reference the correct field names.
  • Simplify Debugging: Quickly identify discrepancies between expected and actual data structures.

Setting Up Postman for API Testing 

Before diving into the details, ensure you have: 

  • Installed Postman 
  • Proper credentials or an access token for your CRM API
  • The base URL for your CRM’s Web API (for example, the Dynamics 365 endpoint) 

Constructing the API Request 

For this demonstration, we’ll assume you want to fetch metadata for a specific entity (e.g., emails). The API endpoint might look something like this: 

GET https://<your-crm-instance>.api.crm.dynamics.com/api/data/v9.2/emails 

Step-by-Step Request Setup 

  • Create a New Request:
    Open Postman and create a new GET request with the URL provided above.

  • Add Authorization: 
    In the GET tab, switch to the Authorization tab. Select Bearer Token as the auth type, and paste your access token into the Token field. This token authenticates your request with the CRM API.

  • Set the Headers:
    In the Headers section, add the following key-value pairs:
Header Name  Value 
Accept  */* 
Prefer  odata.include-annotations=”*” 

 

  • The Prefer header is crucial—it tells the CRM API to include all annotations in the response. These annotations can contain user-friendly names and additional metadata about the ID columns and other attributes.
  • Send the Request:
    Click Send. If everything is set up correctly, you should receive a JSON response containing metadata for the specified entity. Look for annotation properties that detail the display names and other useful information for lookup fields.

Understanding the JSON Response 

The response will be a JSON object that includes various properties about the entity’s attributes. When the Prefer: odata.include-annotations=”*” header is used, you’ll notice additional annotation properties. These might include: 

  • Display Names: Human-friendly names for each attribute, especially useful for lookup columns.
  • Schema Names: The system-defined names that you’ll reference in your code.
  • Data Types and Formats: Information that can be used to validate or format data appropriately in your application.

For example, an attribute definition for a lookup field might include annotations that reveal its associated entity and the user-friendly label of the field—information that is particularly useful when building dynamic forms or data integration layers. 

Before using the Prefer tag: 

After using the Prefer tag: 

Conclusion

Fetching metadata from your CRM system using Postman and the API is a straightforward yet powerful technique. By incorporating the Prefer: odata.include-annotations=”*” header and using the Bearer Token authentication method in the GET tab, you gain access to comprehensive annotation data, including human-readable names for lookup fields and ID columns. This capability not only enhances your development workflow but also ensures that your integrations are more robust and easier to maintain. 

Give it a try in your next project and see how accessing detailed metadata can simplify your CRM customization and integration efforts!

Leave a comment

Your email address will not be published. Required fields are marked *