How to Query Metadata in DataVerse/ Common Data Service using Power Automate

Power Automate is flexible, powerful and not to forget, the future of Power Platform operations. And if you are working on DataVerse or the erstwhile Common Data Service, it is quite improbable that you haven’t worked with the CDS connector in Power Automate.

Yet sometimes it is surprising to see some basic stuffs which could not achieved by Power Automate connectors. And one of them is the ability to Query Metadata of Common data service. The CDS connector or Common Data Service (current environment) connect does not provide the actions query Metadata from a CDS instance.

So how are we going to accomplish the same? While there may not be any any built connectors available with Power Automate to do the same, you can do it using other connectors available there. So let’s accomplish the same.

The first and foremost thing I use is the HTTP connector.

Query Metadata of Common Data Service using Power Automate

And below is the configuration for the Http Action. Here I am firing a GET request. Below is the request url.

https://<crm_url>/api/data/v9.0/EntityDefinitions(LogicalName='account')?$select=DisplayName,IsKnowledgeManagementEnabled,EntitySetName
Query Metadata of Common data Service using Power Automate

Check for the Authentication. I have used “Active Directory OAuth“. Also to make a successful call, you would need to register an app in Azure AD, provide the app permission to access your CDS instance and then add the app as application user in your CDS instance. You can follow this blog here if you not sure of how to do the same.

And now when I run the flow I get the desired results. In this way you can get the results for any metadata WebAPI query. Below is the result from previous query.

{
  "@odata.context": "https://<crmurl>/api/data/v9.0/$metadata#EntityDefinitions(DisplayName,IsKnowledgeManagementEnabled,EntitySetName)/$entity",
  "IsKnowledgeManagementEnabled": false,
  "EntitySetName": "accounts",
  "MetadataId": "70816501-edb9-4740-a16c-6a5efbc05d84",
  "DisplayName": {
    "LocalizedLabels": [
      {
        "Label": "Account",
        "LanguageCode": 1033,
        "IsManaged": true,
        "MetadataId": "2a4901bf-2241-db11-898a-0007e9e17ebd",
        "HasChanged": null
      }
    ],
    "UserLocalizedLabel": {
      "Label": "Account",
      "LanguageCode": 1033,
      "IsManaged": true,
      "MetadataId": "2a4901bf-2241-db11-898a-0007e9e17ebd",
      "HasChanged": null
    }
  }
}

How to parse the results? I am going to explain this in a separate blog. Or even better – You can go ahead try out. I bet you won’t find this difficult.

You may also like the below posts.

Hope this helped!

Debajit Dutta
Business Solutions MVP