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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Web.Contents Assistance with converting URL to PowerQuery

Hi,

 

I have here a very complex API call that I need to do using Power BI. 

 

 

https://wej51919.live.dynatrace.com/api/v2/metrics/query?metricSelector=(builtin:synthetic.browser.event.actionDuration.xhr:filter(and(or(in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log In~~~"~")"))))):splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.actionDuration.load:splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.availability.location.total:splitBy("dt.entity.synthetic_test"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.errorCodes.geo:splitBy("By error code"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.total:splitBy("dt.entity.synthetic_test"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.success:filter(and(or(in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log In~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"Loading of ~~~"https://www.merchantstotalview.com/~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log Out~~~"~")"))))):splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.failure.geo:filter(and(or(in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log In~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"Loading of ~~~"https://www.merchantstotalview.com/~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log Out~~~"~")"))))):splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names&from=2023-04-13 09:25&to=2023-05-04 09:25&resolution=Inf

 

 

 

 

As you can see, the URL has 4 query parameters named metricSelector, from, to, resolution (check the url above).

I am having trouble building the query to connect as it is too complex for me. I have the following code atm, as you can see I am using the RelativePath and Query options.

 

 

 

let
    Source = (Web.Contents(
        "https://wej51919.live.dynatrace.com/api/v2/metrics/",
        [
            RelativePath = "query",
            Query = [
                metricSelector="(builtin:synthetic.browser.event.actionDuration.xhr:filter(and(or(in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log In~~~"~")"))))):splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.actionDuration.load:splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.availability.location.total:splitBy("dt.entity.synthetic_test"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.errorCodes.geo:splitBy("By error code"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.total:splitBy("dt.entity.synthetic_test"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.success:filter(and(or(in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log In~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"Loading of ~~~"https://www.merchantstotalview.com/~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log Out~~~"~")"))))):splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names,(builtin:synthetic.browser.event.failure.geo:filter(and(or(in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log In~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"Loading of ~~~"https://www.merchantstotalview.com/~~~"~")")),in("dt.entity.synthetic_test_step",entitySelector("type(synthetic_test_step),entityName.equals(~"click on ~~~"Log Out~~~"~")"))))):splitBy("dt.entity.synthetic_test_step"):sort(value(auto,descending)):limit(20)):names",

                from="2023-04-13 09:25",
                to="2023-05-04 09:25",
                resolution="Inf"
            ]
        ],

 

 

 

But if I insert the whole content of the metricSelector parameter from the URL, I am having this error below.

lemmagpantay_0-1683221295641.png

This is my first time using this as a datasource so I'm kinda stuck here. I don't know if I need to use escape in the parameter as it has too many "" or am I building it the wrong way? I need your expert advice here. Thanks in advance.

1 REPLY 1
lbendlin
Super User
Super User

yes, you need to encode your URI to avoid conflicts.

 

Uri.BuildQueryString - PowerQuery M | Microsoft Learn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.