Forum Discussion
New table based on iterative API calls
Hello! I have imported a table that is based on a CSV file. It is called table 1. In table 1, there is an "ID" column that needs to be referenced in an API call. Table 1 is below:
I am able to create Table 2 based on this m code:
= Json.Document(Web.Contents("https:api_url_all_the_stuff", [Headers=[Accept="application/json", #"x-api-key"="API_Password_and_key_stuff", #"x-table1-id"="1001"]]))
The problem is that this only refers to a single "ID" from table 1 and there are hundreds of entries for "ID" in table 1.
I need table 2 to look like this:
I would like to make a new table with a single query that iterates each "ID" from table 1 and puts all of the information from the api call in table 2.
Please advise! Kudos and Accepted Solutions are sure to follow.
foodd parry2k amitchandak Greg_Deckler MFelix rajendraongole1
chonchar here are quick steps:
- click advanced editor of table 2 and get the copy of the M code
- start new blank query, click advanced editor and type
(id as text) =>
and after this paste the M codeSave and close and you have M function with Is as parameter
10 Replies
- parry2kSuper User
chonchar create a m function with id as parameter and the use table2 code in this function, replace id with the parameter name.
once it is done, add new column in table 1 and call function (created in step 1) with id as parameter. You will get a table returned from the function and the last step is to expand this new column. This will do it.