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
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
AfsarP1
Helper IV
Helper IV

I see, thanks for confirming @michaelsh 

michaelsh
Kudo Kingpin
Kudo Kingpin

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

AfsarP1
Helper IV
Helper IV

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
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.