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
krixtsup3r
Helper V
Helper V

Hand Authored Queries

 

Hi Can I ask for help in changing the query below to make it work for schedule refresh? I've been going around in the community and web but really can't find a fix for my problem. Thank you so much!

 

let
    baseuri = "https://app.asana.com/api/1.0/projects?limit=100&workspace=*****************&opt_fields=team,name,owner,current_status,due_on,start_on,created_at,modified_at,public,members,custom_fields,custom_field_settings,color,notes,html_notes,workspace,archived",
    headers = [Headers=[#"Content-Type"="application/json", Authorization="Bearer 1/**************************"]],

    initReq = Json.Document(Web.Contents("https://app.asana.com/api/1.0/projects?limit=100&workspace=*****************&opt_fields=team,name,owner,current_status,due_on,start_on,created_at,modified_at,public,members,custom_fields,custom_field_settings,color,notes,html_notes,workspace,archived", headers)),
    initData = initReq[data],
    gather = (data as list, uri) =>
        let
            newOffset = Json.Document(Web.Contents(uri, headers))[next_page][offset],
            newUri = baseuri & "&offset=" & newOffset,
            newReq = Json.Document(Web.Contents(newUri, headers)),
            newdata = newReq[data],
            data = List.Combine({data, newdata}),
            check = if newReq[next_page] = null then data else @gather(data, newUri)
        in check,
    outputList = if initReq[next_page] = null then initData else gather(initData, baseuri),
    expand = Table.FromRecords(outputList),
    
    #"Changed Type" = Table.TransformColumnTypes(expand,{{"created_at", type datetime}, {"modified_at", type datetime}, {"due_on", type date}, {"start_on", type date}}),
    #"Expanded team" = Table.ExpandRecordColumn(#"Changed Type", "team", {"gid"}, {"team.gid"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded team",{ "workspace"}),
    #"Expanded owner" = Table.ExpandRecordColumn(#"Removed Columns", "owner", {"gid"}, {"owner.gid"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Expanded owner",{"current_status", "custom_fields", "custom_field_settings", "members", "html_notes",  "color"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns1",{"gid", "created_at", "modified_at", "start_on", "due_on", "name", "notes", "owner.gid", "team.gid"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Reordered Columns",{{"archived", type text}, {"public", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type1","true","Yes",Replacer.ReplaceText,{"archived", "public"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","false","No",Replacer.ReplaceText,{"archived", "public"})
in
    #"Replaced Value1"

 

10 REPLIES 10
JackSelman
Frequent Visitor

Hey @krixtsup3r, did you manage to solve this? I am having the exact same issue!

v-jingzhang
Community Support
Community Support

Hi @krixtsup3r 

 

In your gather function, below codes would create dynamic url. Maybe this is the cause.

newOffset = Json.Document(Web.Contents(uri, headers))[next_page][offset],
newUri = baseuri & "&offset=" & newOffset,

 

You could refer to Chris Webb's BI Blog: Web.Contents(), M Functions And Dataset Refresh Errors In Power BI

 (as well as other links in this blog directing to his previous blogs). Try using RelativePath and Query options with Web.Contents() to query data. Use a valid static URL as a base URL and put dynamic part in RelativePath or Query options. 

 

Hope this would be helpful.

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

parry2k
Super User
Super User

@krixtsup3r check these posts

 

Power BI: Gateway Monitoring & Administrating- Par... - Microsoft Power BI Community

 

Solved: Refreshing data from REST API works on Desktop, fa... - Microsoft Power BI Community

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Not sure why but the gateway option  is not showing on my end.

krixtsup3r_0-1638753568132.png

 

parry2k
Super User
Super User

@krixtsup3r you need a gateway to make it work. Power BI Gateway | Microsoft Power BI

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi, I have a gateway. Not sure what you meant is there any set up that I need to do?

lbendlin
Super User
Super User

Are you getting a Formula.Firewall warning?  What's the error message?

Hi Im getting the following errors:

if in service:

krixtsup3r_0-1638745755190.png

 

if in desktop:

krixtsup3r_1-1638745776179.png

 

 

Set the privacy settings for the report to Ignore if that is acceptable.

It's already in ignore mode.

krixtsup3r_0-1638753763656.png

 

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.