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
Anonymous
Not applicable

How to dynamically fill the Web.Contents function?

Hi Everyone!

 

Concerning a Web.Contents post call with authorization. How can I let power BI (when trying to make a connection/refresh on the report server) statically evaluate "foo.bar.com/@@login?camefrom=%2F%40%40index" but upon execution the following code should be executed? 

 

 

Source =  Csv.Document(Web.Contents(foo.bar.com, [RelativePath="export/download",Headers=header,Content=Text.ToBinary(body)]),[Delimiter=";"])

 

 

(When logging in "foo.bar.com" is redirected to "foo.bar.com/@@login?camefrom=%2F%40%40index", that's why... in Desktop it all works fine however)

 

Thanks!

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you can try the solution from this post:

Solved: Using Web.Contents with dynamic Google Sheet URL - Microsoft Power BI Community

Google Sheet URL as an example:

  1. In Power BI Desktop, need to go to Option > Privacy and select "Ignore Privacy Level Setting"
  2. In Web.Contents, use relative path to work in Power BI Service as well
  3. In Web.Contents, use "https://docs.google.com" as the basic URL and put the rest in RelativePath.

 

(FileID as text) =>
let
    //FileID = "Google Sheet File ID",
    BasicURL = "https://docs.google.com/",
    RelativePathString = "spreadsheets/d/" & FileID & "/export?format=xlsx",
    Source = Excel.Workbook(Web.Contents(BasicURL, [RelativePath=RelativePathString]), null, true)
//    Source = Excel.Workbook(Web.Contents(BasicURL&RelativePathString))
in
    Source

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you can try the solution from this post:

Solved: Using Web.Contents with dynamic Google Sheet URL - Microsoft Power BI Community

Google Sheet URL as an example:

  1. In Power BI Desktop, need to go to Option > Privacy and select "Ignore Privacy Level Setting"
  2. In Web.Contents, use relative path to work in Power BI Service as well
  3. In Web.Contents, use "https://docs.google.com" as the basic URL and put the rest in RelativePath.

 

(FileID as text) =>
let
    //FileID = "Google Sheet File ID",
    BasicURL = "https://docs.google.com/",
    RelativePathString = "spreadsheets/d/" & FileID & "/export?format=xlsx",
    Source = Excel.Workbook(Web.Contents(BasicURL, [RelativePath=RelativePathString]), null, true)
//    Source = Excel.Workbook(Web.Contents(BasicURL&RelativePathString))
in
    Source

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors
Top Kudoed Authors