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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
RobHess05
Helper I
Helper I

Set the Host header my Power Query

My API has a requirement to set the Host in the header, but Power BI throw an error when I try:

RobHess05_0-1711537148982.png

 

The code looks good, and works if I set other values in the header.  It just throws an error if I set the Host.  What's the best way to do this?

 

Source = Value.Metadata(Web.Contents("https://www.borat.net/wp-json/wp/v2/posts?_fields=date,modified,link,title,author,comment_status,status&per_page=100&orderby=modified&order=desc", [ Headers = [#"Host" = "www.borat.net"] ])),

 

3 ACCEPTED SOLUTIONS
v-yangliu-msft
Community Support
Community Support

Hi  @RobHess05 ,

 

Based on my understanding, this issue may now still be related to the API can't be run successfully with this host name. Please first try to run the API with the host correct value in the third party tool Post Man until successfully get the response, then you can try to run the same API request in the same format (same header and body) in the Power query:

Postman API Platform | Sign Up for Free

vyangliumsft_0-1711609416787.jpeg

 

Best Regards,

Liu Yang

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

let
    Source = Value.Metadata(Web.Contents("https://www.beringer.net", [Headers=[Referer="www.beringer.net"]]))
in
    Source

View solution in original post

Thank you.  Power BI does accept Referer, but I need to use 'Host' in the Header.

Here's my Postman example with Host in the header, which returns a header with very specific attributes

RobHess05_0-1712099045189.png

 

Here's my example with Referer in the Header

RobHess05_1-1712099140843.png

 

I need to pull that value out of the header to handle paging.  Does Power BI allow 'Host' in the header?

View solution in original post

5 REPLIES 5
RobHess05
Helper I
Helper I

Thank you for the reply @v-yangliu-msft .  Yes, this works well in Postman.  

Here's the actual let query that throws the error in Power BI:

let
    Source = Value.Metadata(Web.Contents("https://www.beringer.net/wp-json/wp/v2/posts?_fields=date,modified,link,title,author,comment_status,status&per_page=100&orderby=modified&order=desc", [ Headers = [#"Host" = "www.beringer.net"] ])),

and here's the working Postman request

RobHess05_0-1712067794746.png

 

It's an open API, so you should be able to reproduce the error if you try my query from Power BI.

let
    Source = Value.Metadata(Web.Contents("https://www.beringer.net", [Headers=[Referer="www.beringer.net"]]))
in
    Source

Thank you.  Power BI does accept Referer, but I need to use 'Host' in the Header.

Here's my Postman example with Host in the header, which returns a header with very specific attributes

RobHess05_0-1712099045189.png

 

Here's my example with Referer in the Header

RobHess05_1-1712099140843.png

 

I need to pull that value out of the header to handle paging.  Does Power BI allow 'Host' in the header?

Does Power BI allow 'Host' in the header?

 

apparently not.  If this is important to you please consider voting for an existing idea or raising a new one at https://ideas.fabric.microsoft.com/?forum=2d80fd4a-16cb-4189-896b-e0dac5e08b41

v-yangliu-msft
Community Support
Community Support

Hi  @RobHess05 ,

 

Based on my understanding, this issue may now still be related to the API can't be run successfully with this host name. Please first try to run the API with the host correct value in the third party tool Post Man until successfully get the response, then you can try to run the same API request in the same format (same header and body) in the Power query:

Postman API Platform | Sign Up for Free

vyangliumsft_0-1711609416787.jpeg

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Kudoed Authors