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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
michaelsh
Kudo Kingpin
Kudo Kingpin

Host Header error in an API call

I have an API call that works in Postman (GET)

It is a OAuth 1.0 authentiacation and I have all keys, secrets and signature.

When I do it in Power Query - I just try to replicate the Headers that Postman.

One of the headers in Postman is "Host" header. Without it - the request doesn't work in Postman. With it - it works.

When I look in Console - it just sends Host: "myurl.com" header.

When I add it in my Power Query request (see in red below) - it suddenly shows an error:

Expression.Error: The 'Host' header must be modified using the appropriate property or method (please see below picture in yellow)

When I click "Edit Settings" - I just get a JSON settings screen - attached.

I tried passing a parameter instead of "myurl.com" - same error.

Other headers don't throw this error.

Without it - it doesn't work either.

Below is the full step code.

Please help!

 

= Json.Document(Web.Contents("https://myurl.com", [
Headers=[
#"Accept" = "application/schema+json",
#"Authorization"= "OAuth realm=""XXXX"",oauth_consumer_key=""YYY"",oauth_token=""TTTT"",oauth_signature_method=""HMAC-SHA256"",oauth_timestamp=""123456"",oauth_nonce=""ZZZZZ"",oauth_version=""1.0"",oauth_signature=""DDDDDD""",
#"Host" = "myurl.com"
],
RelativePath = "/api/v1/student"
]))

 

Screenshot 2020-10-17 154101.png

 

Screenshot 2020-10-17 154101.jpg

 

5 REPLIES 5
Anonymous
Not applicable

I see, thanks for confirming @michaelsh 

michaelsh
Kudo Kingpin
Kudo Kingpin

@Anonymous  No, sorry, I gave up on this Oauth API and went to ODBC instead...

Anonymous
Not applicable

Hi @michaelsh 

 

Were you able to resolve that issue. I'm also struck with this issue:

 

Expression.Error: The 'Host' header must be modified using the appropriate property or method.

michaelsh
Kudo Kingpin
Kudo Kingpin

A little update - I removed the Json.Document, leaving just the Web.Contents part.

I also removed the Accept header.

Same error. Now it I click "Edit Settings" I just see the "From Web" settings where it correctly recognizes my headers.

It just doen't like the "Host" header somehow...

I've played with its values - same error, it just doesn't like this header being there...

Any ideas? Please help...

 

Screenshot 2020-10-17 1541021.jpg

 

Hi @michaelsh,

Have tried to use any other methods to invoke your api? AFAIK, normally power query web connector not required 'host' parameters. Maybe you can try to split the authorizations string to standalone parameters and remove 'host'.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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