Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dynamically calling of API

Hello, I need to dynamically call API based on table column value.   Table 1:   Id TokenID 1 ABCD 2 EFGH 3 PQRS 5 XYZ   We need to gather amount in...
  • PhilipTreacy's avatar
    4 years ago

    Hi Anonymous 

    See this PBIX file for a working example.

    You can create a function and call the API from inside that, passing in the ID and TokenID for each row.

    The code within the function looks something like this

    Source = Web.BrowserContents("https://website.com/id="&id&"&tokenid="&tokenid)

    And for each row you have code that calls the function like this

    = Table.AddColumn(#"Changed Type", "API Call", each APICall(Text.From([Id]), [TokenID]))

    You will of course need to enter the correct website address in the function to reach your API.

    You also make no mention of needing authentication to the API so no code for this is included.

    Regards

    Phil