Forum Discussion
POST http(s) request with xml content in Power Query
Hi Guys,
- The problem to solve: read stocks of a product
- Target webpage= https://www.vinmonopolet.no/vmp/Land/Chile/Gato-Negro-Cabernet-Sauvignon-2014/p/295306
- Link to stock= "Finn butikk med varen på lager" (Find a store with stocks) you need to click there.
4. The code I'm using is here:
Source =
Xml.Document(Web.Contents("https://www.vinmonopolet.no/vmp/store-pickup/295306/pointOfServices",
Accept= "*/*",
AcceptEncoding= "gzip, deflate, br",
AcceptLanguage= "en-US,en;q=0.9,nb;q=0.8,es;q=0.7,ru;q=0.6",
Connection= "keep-alive",
ContentLength= "123",
ContentType= "application/x-www-form-urlencoded; charset=UTF-8",
Host = "www.vinmonopolet.no",
Origin = "https://www.vinmonopolet.no",
Referer = "https://www.vinmonopolet.no/vmp/Land/Chile/Gato-Negro-Cabernet-Sauvignon-2014/p/295306",
UserAgent= "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
XRequestedWith = "XMLHttpRequest"
]]))
in
Source
But I'm getting the following error:
Expression.Error: The 'Host' header must be modified using the appropriate property or method.
Any ideas about how to solve it:
- Making and call to R scripts using Rseleniun (With docker) Difficult I will love to keep it simple and reproducible to other users.
BR
/Pato
5 Replies
- v-chuncz-msftCommunity Support
- patoduckHelper III
You need to have it else you get 400 response. See below.
DataSource.Error: Web.Contents failed to get contents from 'https://www.vinmonopolet.no/vmp/store-pickup/295306/pointOfServices' (400): Bad Request
Details:
DataSourceKind=Web
DataSourcePath=https://www.vinmonopolet.no/vmp/store-pickup/295306/pointOfServices
Url=https://www.vinmonopolet.no/vmp/store-pickup/295306/pointOfServices- andreyminakovFrequent Visitor
I see the same problem not only with Host, but with with Content-Type as well. I found this post regarding the problem - http://blogs.clariusconsulting.net/kzu/setting-http-headers-in-net-this-header-must-be-modified-using-the-appropriate-property/
And I get 400 responce without these parameters as well.
Possibly guys from Power Query team modify headers using not appropriate C class level ;-).