Forum Discussion
Dynamic Data Sources and API
Hello! I am trying to figure out how to modify the below code so that I can refresh in the PowerBI service without the Dynamic Data Source error. Getting 100 rows at a time and just paging for new records. It works on the desktop. I have read several articles, blogs and this forum but for the life of me cannot figure out what to do. Can anyone help? Thanks so much!
let Source = Json.Document(Web.Contents("https://XXXX.XXXXX.com/api/v1/" & "XXXXXXXXX.json" & "?_limit=100", [Headers=[#"Content-Type"="application/json", Authorization="Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]])), totalPagesOrganizationPeople = (Source[count]/100), CreateList = List.Numbers(0,totalPagesOrganizationPeople,100), #"Converted to Table" = Table.FromList(CreateList, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Json.Document(Web.Contents("https://XXXX.XXXXX.com/api/v1/" & "organizations.json" & "?_limit=100" & "&_offset=" &[Column1], [Headers=[#"Content-Type"="application/json", Authorization="Token XXXXXXXXXXXXXXXXXXXXXXXXXXXX"]]))), #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"results"}, {"Custom.results"}), #"Expanded Custom.results" = Table.ExpandListColumn(#"Expanded Custom", "Custom.results"), #"Expanded Custom.results1" = Table.ExpandRecordColumn(#"Expanded Custom.results", "Custom.results", {"url", "id", "organization", "person", "groups", "data", "alternate_id", "admin_notes", "documents", "status", "myuserpermissions", "assigned_programs", "created", "created_by", "modified", "modified_by"}, {"results.url", "results.id", "results.organization", "results.person", "results.groups", "results.data", "results.alternate_id", "results.admin_notes", "results.documents", "results.status", "results.myuserpermissions", "results.assigned_programs", "results.created", "results.created_by", "results.modified", "results.modified_by"}) in #"Expanded Custom.results1"
9 Replies
- lbendlinSuper User
You need to change your code to use RelativePath and Query
Web.Contents - PowerQuery M | Microsoft Learn
- DPCCGFHelper IV
Hey, I can give this a shot but am under a small time crunch. If you want to make a little holiday money feel free to quote me to give me an example that I can use and apply to other similar API queries I have. They are just against other json tables that pull in 100 records per page. TIA
- lbendlinSuper User
Please check the example 1 at the link I included. It is straightforward.
As you can probably appreciate it is nearly impossible to help with API queries without access to said API (which you may not be willing to provide for understandable reasons)