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.
Hello,
Refreshing a dataset in Power BI service that comes from a web content like REST API's has always been a pain in the ass but I've found to do it with using relative path. My example is which I call the REST API of Zendesk to get the groups. The first example works in my Power BI service and it refreshes my dataset.
let Source = (ClientID as text, ClientSecret as text, LoginName as text, Password as text) => let ZendeskAccessTokenContent = [ grant_type = "password", client_id = ClientID, client_secret = ClientSecret, scope = "read", username = LoginName, password = Password ], ConvertZendeskAccessTokenContent = Text.ToBinary(Uri.BuildQueryString(ZendeskAccessTokenContent)), ZendeskAccessTokenRequest = Web.Contents("https://blabla.zendesk.com", [ RelativePath = "/oauth/tokens", Headers = [#"Content-Type"="application/x-www-form-urlencoded"], Content = ConvertZendeskAccessTokenContent ] ), ZendeskAccessTokenJSON = Json.Document(ZendeskAccessTokenRequest), GetZendeskAccessToken = ZendeskAccessTokenJSON[access_token], ZendeskGroupsRequest = Web.Contents("https://blabla.zendesk.com", [RelativePath = "/api/v2/groups.json", Headers = [#"Authorization"="Bearer " & GetZendeskAccessToken, #"Content-Type"="application/json"]]), ZendeskGroupsJSON = Json.Document(ZendeskGroupsRequest), ZendeskGroupsList = @ZendeskGroupsJSON[groups], ExpandListOfRecords = Table.FromRecords(ZendeskGroupsList), GetSelectedColumns = Table.SelectColumns(ExpandListOfRecords, {"id", "name", "deleted", "created_at", "updated_at"}), RenameSelectedColumns = Table.RenameColumns(GetSelectedColumns, {{"id", "ID"}, {"name", "Name of Group"}, {"deleted", "Is Deleted"}, {"created_at", "Created at"}, {"updated_at", "Updated at"}}), ChangeTypeSelectedColumns = Table.TransformColumnTypes(RenameSelectedColumns, {{"ID", type text}, {"Name of Group", type text}, {"Is Deleted", type logical}, {"Created at", type datetime}, {"Updated at", type datetime}}) in ChangeTypeSelectedColumns in Source
In my second example I use some sort of iteration to loop over the next pages with a next link value. If I want to use a relative path, this doesn't work. Maybe it has something to do with GetURLParameter.
let Source = (ClientID as text, ClientSecret as text, LoginName as text, Password as text) => let ZendeskAccessTokenContent = [ grant_type = "password", client_id = ClientID, client_secret = ClientSecret, scope = "read", username = LoginName, password = Password ], ConvertZendeskAccessTokenContent = Text.ToBinary(Uri.BuildQueryString(ZendeskAccessTokenContent)), ZendeskAccessTokenRequest = Web.Contents("https://blabla.zendesk.com", [ RelativePath = "/oauth/tokens", Headers = [#"Content-Type"="application/x-www-form-urlencoded"], Content = ConvertZendeskAccessTokenContent ] ), ZendeskAccessTokenJSON = Json.Document(ZendeskAccessTokenRequest), GetZendeskAccessToken = ZendeskAccessTokenJSON[access_token], GetURLParameter = (URL) => let ZendeskGroupsRequest = Web.Contents(URL, [RelativePath = "/api/v2/groups.json", Headers = [#"Authorization"="Bearer " & GetZendeskAccessToken, #"Content-Type"="application/json"]]), ZendeskGroupsJSON = Json.Document(ZendeskGroupsRequest), ZendeskGroupsList = @ZendeskGroupsJSON[groups], IterationOverNextPage = try @ZendeskGroupsList & @GetURLParameter(ZendeskGroupsJSON[next_page]) otherwise @ZendeskGroupsList in IterationOverNextPage, GetAllZendeskGroups = GetURLParameter("https://blabla.zendesk.com"), ExpandListOfRecords = Table.FromRecords(GetAllZendeskGroups), GetSelectedColumns = Table.SelectColumns(ExpandListOfRecords, {"id", "name", "deleted", "created_at", "updated_at"}), RenameSelectedColumns = Table.RenameColumns(GetSelectedColumns, {{"id", "ID"}, {"name", "Name of Group"}, {"deleted", "Is Deleted"}, {"created_at", "Created at"}, {"updated_at", "Updated at"}}), ChangeTypeSelectedColumns = Table.TransformColumnTypes(RenameSelectedColumns, {{"ID", type text}, {"Name of Group", type text}, {"Is Deleted", type logical}, {"Created at", type datetime}, {"Updated at", type datetime}}) in ChangeTypeSelectedColumns in Source
Can someone help me with this?
Kind regards
Solved! Go to Solution.
Unfortunately this limitation is still true: "Queries where data access happens inside a function and where the data source is dependent on parameters to the function can't currently be refreshed in Power BI Service. " (Source: https://community.powerbi.com/t5/Issues/Unable-To-Refresh-Queries-Which-Are-Using-Functions-As-a/idi...)
Also see comment from Kurt Hagenlocher in this thread: https://social.technet.microsoft.com/Forums/en-US/208b9365-91e9-4802-b737-de00bf027e2a/alternative-c...
Pls upvote feature requests here:
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @naelske_cronos ,
AFAIK, I think this should more related to in iteration looping part.(relative path works on service side, iteration looping may blocked by power bi security settings)
@ImkeF @MarcelBeugAny suggestion for this scenario?
Regards,
Xiaoxin Sheng
Unfortunately this limitation is still true: "Queries where data access happens inside a function and where the data source is dependent on parameters to the function can't currently be refreshed in Power BI Service. " (Source: https://community.powerbi.com/t5/Issues/Unable-To-Refresh-Queries-Which-Are-Using-Functions-As-a/idi...)
Also see comment from Kurt Hagenlocher in this thread: https://social.technet.microsoft.com/Forums/en-US/208b9365-91e9-4802-b737-de00bf027e2a/alternative-c...
Pls upvote feature requests here:
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |