Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

CompanyID is not returning from Business central for BC API Companies

Hello all,

 

 

 

I have multiple companies in the Microsoft Dynamics 365 Business Central environment, so i want to pull all of those company IDs using REST API for automating some processes. So I went through the API documentation of Microsoft to get the companies list with IDs.

GET companies - Business Central | Microsoft Learn

 

In the API response, it's mentioned that it will return the companyId for each company. So I implemented the same using Fabric Data Pipeline, but am not getting the CompanyID from the API response. Is there any reason? I'm using Bearer token authentication only but still am not seeing the CompanyID in api response

 

Pipeline

 

 

Actual API response coming from data pipeline

 

 

Expected API Response from Microsoft

 

 

Is there any other way to pull the CompanyIDs of Business Central companies using Fabric data pipelines. Am i missing anything can anyone suggest me please and help me in resolving it.

 

 

Thanks in advance, any help is really appreciated.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi nilendraFabric 

     

    Thanks, am able to get the CompanyID information from Postman and even with Spark notebooks also, not sure why pipelines is not returning the CompanyID.

     

    I implemented the Bearer token authentication approach in notebook and loading the data to fabric lakehouse in config table from there am referencing it for my needs.

     

     

4 Replies

  • Hi Anonymous 

     

    Ensure your Bearer token has adequate permissions by checking the Azure AD app registration and its role assignments in Business Central

     

    Use tools like Postman or Power Query to directly test the API endpoint and confirm whether `CompanyID` is returned outside of Fabric Data Pipeline

    If the issue persists, consider using Power Query or Spark Notebooks within Fabric to extract data directly from Business Central APIs

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi nilendraFabric 

       

      Thanks, am able to get the CompanyID information from Postman and even with Spark notebooks also, not sure why pipelines is not returning the CompanyID.

       

      I implemented the Bearer token authentication approach in notebook and loading the data to fabric lakehouse in config table from there am referencing it for my needs.

       

       

  • v-prasare's avatar
    v-prasare
    Icon for Community Support rankCommunity Support

    Hi Anonymous,

    Thanks for reaching MS FAbric commmunity support.

     

     

    Possible Causes:

    API Version Difference: The expected API response in the Microsoft documentation includes "id", but your actual response does not. Ensure you're using the latest Business Central API version (v2.0 or higher).

     

    Incorrect API Endpoint: Double-check the API endpoint you are using. It should be:

    https://api.businesscentral.dynamics.com/v2.0/{tenantId}/production/api/v2.0/companies

    Ensure you have replaced {tenantId} with your actual tenant ID.

     

    Missing Permissions in Azure AD App Registration: Your Azure AD app may not have the necessary permissions.

    Ensure the app has Financials.ReadWrite.All or Financials.Read.All permissions in Azure AD.

     

    API Query Parameters: Try adding $select=id,name to your request:

    https://api.businesscentral.dynamics.com/v2.0/{tenantId}/production/api/v2.0/companies?$select=id,name

    This ensures only relevant fields (id, name) are retrieved.

     

     

     

    Thanks,

    Prashanth Are

    MS Fabric community support

  • Anonymous's avatar
    Anonymous
    Not applicable

    Yes i tried this but still seeing the response like this below even I filtered with id and name also