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

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.

Reply
naelske_cronos
Helper III
Helper III

Power BI service - Refresh unsupported source

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

1 ACCEPTED 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

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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