Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

NESTED API CALLS

Hello I am trying to do a nested API call using M language.

Step 1) The Code makes a call List of links.  

Step 2) The links are in csv format.

Step 3) Each link turns into a table

Step 4) Want to merge all the tables into one big table?

 

Source = scenarios,
#"Changed Type1"=Table.SelectColumns(Source,"Scenario_API_URL"),

#"Changed Type0"= Table.FromRecords({[API_URL = Table.SelectColumns(#"Changed Type1","Scenario_API_URL")]}),
#"Expanded API_URL" = Table.ExpandTableColumn(#"Changed Type0", "API_URL", {"Scenario_API_URL"}, {"API_URL.Scenario_API_URL"}),
#"scenario count"=Table.RowCount(#"Expanded API_URL"),

 

Generating List using the CSV data

#"New List" =
List.Generate(()=> [ NewTable={},x = 1 , y = {}] , each [x] < #"scenario count" , each [
test = Csv.Document(Web.Contents( #"Expanded API_URL"{x}[API_URL.Scenario_API_URL] ,[Headers=[Authorization="Token token=""API TOKEN"""]]),[Delimiter=",", Columns=30, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Converted to Table" = Table.FromList(test, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
x = [x] + 1
] ,
each [ test]
),

 

//Promote Header for each table From #"New List"
#"New List2" =
List.Generate(()=> [ x = 1 , y = {}] , each [x] < #"scenario count" , each [y = {Table.PromoteHeaders(#"New List"{x}, [PromoteAllScalars=true])},x=[x]+1] , each [y]),

 

// Now I just want to combine all the tables In to one big table.
#"New List3" =
List.Generate(()=> [ x = 1, k = {} , #"myEmptyTable" = #table({"Email"})] , each [x] < #"scenario count" , each [#"ResultSet"=Table.Combine({#"New List2"{x}}),x=[x]+1] , each [#"ResultSet"])
in
#"New List3"

 

The tables does have different numbers of column and rows. My question is I get "Forbidden Access" when I try to combine the tables into one table. 

 

1 REPLY 1
v-joesh-msft
Solution Sage
Solution Sage

Hi @Anonymous ,

Please check if the access token is legal. If it is legal, please check if it has expired.

Best Regards,

Community Support Team _ Joey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.