Forum Discussion
Komi
4 years agoFrequent Visitor
Get Data from cURL with Power Query
Hi, I need help - I have a cURL and I need to transform it into a power query. Can someone please help me? curl --request POST \
--url https://api.abcd.com/2/ \
--header 'accept: applicatio...
simcla
3 years agoRegular Visitor
Thank you for this solution!
I tried to use it to access HomeAssistant using the API interface.
The Curl-Statement is as follows and works fine:
curl \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....." \
-H "Content-Type: application/json" \
http://homeassistant:8123/api/servicesI did translate it in PowerQuery to this statement:
let
url = "http://homeassistant:8123/api/services",
headers = [Authorization="Bearer eyJhbGciOiJIUzI1NiIsInR5cC....",
#"Content-Type"="application/json"],
response = Web.Contents(
url,
[ Headers = headers ]
),
jsonResponse = Json.Document(response)
in
jsonResponsebut only got this message:
Unerwarteter Fehler.: Die Blocklänge stimmt nicht mit ihrem Komplement überein.
Details:
Microsoft.Mashup.Evaluator.Interface.ErrorException: Die Blocklänge stimmt nicht mit ihrem Komplement überein. --->
Microsoft.Mashup.Evaluator.Interface.ErrorException: Die Blocklänge stimmt nicht mit ihrem Komplement überein. --->
Microsoft.Mashup.Evaluator.Interface.ErrorException: Die Blocklänge stimmt nicht mit ihrem Komplement überein. --->
Microsoft.Mashup.Evaluator.Interface.ErrorException: Die Blocklänge stimmt nicht mit ihrem Komplement überein. --->
Microsoft.Mashup.Evaluator.Interface.ErrorException: Die Blocklänge stimmt nicht mit ihrem Komplement überein. --->
System.IO.InvalidDataException: Die Blocklänge stimmt nicht mit ihrem Komplement überein. --->
System.IO.InvalidDataException: Die Blocklänge stimmt nicht mit ihrem Komplement überein.
bei System.IO.Mashup.Compression.Inflater.DecodeUncompressedBlock(Boolean& end_of_block)
bei System.IO.Mashup.Compression.Inflater.Decode()
bei System.IO.Mashup.Compression.Inflater.Inflate(Byte[] bytes, Int32 offset, Int32 length)
.........................Sorry, the error message is in german. It reads something like
"Unexpected Error. The block length does not match its complement."
Any idea what is wrong with my code ?
Thanks in advance!
simcla
3 years agoRegular Visitor
In the meanwhile I found a solution. You have to add
#"Accept-Encoding" = "gzip"
to your code:
let
url = "http://homeassistant:8123/api/history/period?filter_entity_id=sensor.xxxxx",
headers = [Authorization="Bearer eyJhbGciOiJIUzI1NiIsI....",
#"Content-Type"="application/json",
#"Accept-Encoding" = "gzip"],
response = Web.Contents(
url,
[ Headers = headers ]
), ............................
Thanks to Chris Webb!