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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.