Forum Discussion

DaveHayter's avatar
DaveHayter
Regular Visitor
11 months ago
Solved

Pulling multiple API lines using a list of ID references

Hello,   I have two API lookups that I need to try and work with. I can pull them both individually, but what I need is as follows;   API 1 returns to me a list of all certain locations within an...
  • v-veshwara-msft's avatar
    v-veshwara-msft
    11 months ago

    Hi DaveHayter ,

    Thanks for reaching out to Microsoft Fabric Community and thanks for the update.

    If the API requires an authentication key, you can include it securely without hard-coding the key in the query. Power Query supports using the ApiKeyName option with Web.Contents, which allows you to store and manage the key through the Web API authentication method rather than embedding it directly in the M code. For example:

    Web.Contents("https://contoso.com/api/customers/get", [ApiKeyName = "api_key"])

    When configured this way, Power BI will prompt for the key in the credential dialog, and the value will be stored securely. You can refer to the official documentation here: Web.Contents - PowerQuery M | Microsoft Learn

     

    If the API expects the key in a header rather than a query string, you can continue using the Headers record inside Web.Contents, for example "Ocp-Apim-Subscription-Key" or "x-api-key", depending on the API specification.

    Subscriptions in Azure API Management | Microsoft Learn

     

    Using Table.AddColumn() to call the second API for each record works fine. Just make sure the main part of the API URL stays the same and only the changing parts (like IDs or dates) are passed through RelativePath or Query. This helps avoid refresh issues in the Power BI service.

     

    You can find more details on structuring API calls securely in Power Query here:

    Web.Contents - PowerQuery M | Microsoft Learn

    Handling authentication for Power Query connectors - Power Query | Microsoft Learn

     

    Similar error: Solved: Access to the resource is forbidden error while ac... - Microsoft Fabric Community

     

    Hope this helps. Please reach out for further assistance.

    Thank you.

    Thanks danextian for sharing your valuable inputs.