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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
KUK1390
Frequent Visitor

PowerBI - Relative Path

Hi everybody,

I wondering if anyone can help me please, I am trying to amend my code to use Relative Path. 

I have spent a few weeks setting up this report up but when I went to refresh the sources it wouldn't let me.

 

 

(page as number) as record =>
let
Source = Json.Document(Web.Contents("https://BP.com/public-api/testings/order-service/order/" & Number.ToText(page) & "-" & Number.ToText(page+199) & "?includeOptional=customFields,nullCustomFields,postalAddresses", [Headers=[#"bp-app-ref"="kieran", #"bp-account-token"="token"]]))
in
Source

 

 



Is it possible to change it to relative path with headers etc, I have hit a brick wall.

Thank you.

1 ACCEPTED SOLUTION
jbwtp
Memorable Member
Memorable Member

I think the code may look like this:

(page as number) as record =>
    let
        Source = Web.Contents(
                        "https://BP.com/public-api",
                        [
                            RelativePath = "testings/order-service/order/" & Number.ToText(page) & "-" & Number.ToText(page+199),
                            Query = [includeOptional="customFields,nullCustomFields,postalAddresses"], 
                            Headers=[#"bp-app-ref"="kieran", #"bp-account-token"="token"]
                        ]),
        json_doc = Json.Document(Source) 
    in
        json_doc

View solution in original post

5 REPLIES 5
KUK1390
Frequent Visitor

Hi, 

I am still struggling to convert the above code. I keep getting errors. I will post my code shortly.

jbwtp
Memorable Member
Memorable Member

I think the code may look like this:

(page as number) as record =>
    let
        Source = Web.Contents(
                        "https://BP.com/public-api",
                        [
                            RelativePath = "testings/order-service/order/" & Number.ToText(page) & "-" & Number.ToText(page+199),
                            Query = [includeOptional="customFields,nullCustomFields,postalAddresses"], 
                            Headers=[#"bp-app-ref"="kieran", #"bp-account-token"="token"]
                        ]),
        json_doc = Json.Document(Source) 
    in
        json_doc
KUK1390
Frequent Visitor

Hi jbwtp,

This worked perfectly, I can see exactly where I went wrong too. I was breaking down the URL incorrectly.

This has somehow broken some of the visuals, not sure why but should be an easy fix.

Again, Kudo's to you! 

PREVIEW
 
 
 
KUK1390
Frequent Visitor

Hi jbwtp. 

Many thanks for replying. 

I did have a look at that yesterday but was unsure how to build the query. 

I am going to have another play today and hopefully I will get it working.

The end goal is to have it so my published report can be refreshed.

jbwtp
Memorable Member
Memorable Member

Hi @KUK1390,

 

Did you try this? Chris Webb's BI Blog: Using The RelativePath And Query Options With Web.Contents() In Power Query An...

This is for Query, but Headers should be working in the same way.

 

Kind regards,

John

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.