Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
This is my first attempting at consuming Rest APIs through power query. After much struggle, i am able to make an API call successfully. It returns only 80 records. The documentation says that I have to append page number at the end of the query string to succesfully paginate.
Something like this:
let
Source = Web.Page(Web.Contents("https://" , [Headers=[Authorization="Token XXXXXXXXXX", #"Content_Type"="application/json"]],
[RelativePath="?page=" & Number.ToText(page),
Query=[Headers=
[Authorization="xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Content_Type="application/json"]]]))
in
Source
Essentially I need to code to dynamically change the "page=" over any number of pages it may be. Could you please help me to complete the code
I got this code but I can't get it to work:
Thanks for your answer Mark, now it generates the following error:
Expression.Error: 3 arguments were passed to a function which expects between 1 and 2.
Details:
Pattern=
Arguments=[List]
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below. Not sure why you need Web.Page and Web.Contents. Usually just Web.Contents is needed.
let
Source = List.Numbers(1, 10,1),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "PageNumber"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "WebContents", each Web.Page(Web.Contents("https://" , [Headers=[Authorization="Token XXXXXXXXXX", #"Content_Type"="application/json"]],
[RelativePath="?page=" & [PageNumber],
Query=[Headers=
[Authorization="xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Content_Type="application/json"]]])))
in
#"Added Custom"
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |