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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
larsthelord
Regular Visitor

Web source AcceptLanguage HTTP request header not working?

 Hey! 

I have tried to import imdb top 250 movies through the url: "https://www.imdb.com/chart/top"
This produces a list with movie titles in my regional language, and  this is also how they appear in Edge.

This is controlled by the "Accept-Language" header in the request. The header in Edge is as follows: 
"Accept-Language: nb, en-US; q=0.7, en; q=0.3"

This is taken based on the listed languages in the Region & Language - Preferred languages settings in Windows.

 

If i move english to the top of the preferred languages (This is not preferred to me, since this changes the initial language used for the keyboard when starting windows) the "Accept-Language" header also changes in Edge: 
"Accept-Language: en-US, en; q=0.7, nb; q=0.3"
and Edge now returns the English titels fro the movies. 

I then saw that the import from website fucntion has the option for setting header values. From the advanced setting in the GUI I set the header to "AcceptLanguage" and the value to the one produced by Edge, shown above. 
The data was still imported with regional names. I tried changing the value to "en", "en-US", "en-US,en" but nothing works. 

When I change the language setting in Region & Language - Preferred languages settings in Windows, the movies are imported in English, in basic settings and in advanced settings, even if i set the "AcceptedLanguage" to nb which is my regional language. 

The code made by the GUI is in the advanced editor shown as: 
Source = Web.Page(Web.Contents("https://www.imdb.com/chart/top", [Headers=[AcceptLanguage="en-US, en; q=0.7, nb; q=0.3"]]))

After all this information, my question is: 
Am I doing something wrong when using the GUI, or is Power BI not handling the AcceptLanguage header correctly?

 

Thanks!

 

 

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @larsthelord

Does this cause any errors?

Could you paste the screenshot of the error here?

 

Best Regards

Maggie

No, the problem isn't that it produces any errors. 
The problem is that it seems to load the same language specifics from the IMDb based on system settings, and not in the specified "AcceptLanguage" header from "advanced" settings in the GUI. 

 

It should be able to get different responses from imdb.com based on the "Accept-Language" header in the web request, but this does not change when this header is changed in the Power BI function. 
It does however change when I change the system settings on my computer, and that's not very automation friendly 😞

 
So to summarize my problem in code: 
Source1 = Web.Page(Web.Contents("https://www.imdb.com/chart/top", [Headers=[AcceptLanguage="en-US"]]))

Source2 = Web.Page(Web.Contents("https://www.imdb.com/chart/top", [Headers=[AcceptLanguage="nb"]]))

 

Source1 should return movie titles in English, Source2 should return movie titles in Norwegian, but they both return the same movie titles, which correspond to my system language settings.

 

If only there was some way to view the web request from Power BI, then I could see if the function does what it's supposed to, or how it's actually handled.

 

P.S.

(I see that Power Query lists headers without the "AcceptLanguage" without the hyphen "-" which is in shown in the Edge browser "Accept-Language", but I am guessing this is because of Power Query semantics, and not the actual problem.)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.