Forum Discussion
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
- v-jingzhangCommunity Support
Hi Anonymous
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. - lbendlinSuper User
Are you getting a Formula.Firewall warning? What's the error message?
- AnonymousNot applicable
Hi Im getting the following errors:
if in service:
if in desktop:
- lbendlinSuper User
Set the privacy settings for the report to Ignore if that is acceptable.
- parry2kSuper User
Anonymous 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.⚡
- AnonymousNot applicable
Hi, I have a gateway. Not sure what you meant is there any set up that I need to do?
- parry2kSuper User
Anonymous 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.⚡
- AnonymousNot applicable
Not sure why but the gateway option is not showing on my end.
- JackSelmanHelper I
Hey Anonymous, did you manage to solve this? I am having the exact same issue!