Forum Discussion
Access data from POST API
- Anonymous5 years ago
HI Anonymous,
>>DataSource.Error: The downloaded data is HTML, which isn't the expected type. The URL may be wrong or you might not have provided the right credentials to the server.
Perhaps this issue appears when you try to use the wrong connector to recognize response data.
I'd like to suggest you navigation to the 'Source' step to confirm the result type and change to the corresponding connector in the next steps to recognize/analytics records.Regards,
Xiaoxin Sheng
Here is an example. Use Json.FromValue to binary encode your payload
let
URL = "http://xxx/tstat",
headers = [#"Content-Type"="application/json"],
data = Json.FromValue([tmode = 2,t_cool = Setpoint,hold = 0]),
web = Web.Contents(URL, [ Content = data, Headers = headers, ManualStatusHandling = {404, 400}]),
result = Json.Document(web)
in
result
- lbendlin5 years agoSuper User
This is Power Query (also referred to as M) . You use that to connect to your data sources.
If you are new to Power BI then you may want to start with an easier project. Running POST calls is rather advanced.
- Anonymous5 years agoNot applicable
Hi lbendlin
Sorry It's my bad, I mean to say, is it need to type in the Advance editor of Power Query Editor?
Also having one question, Where to add the Header Name (i.e,- X-Token) and jwd token generated from the payload.
- lbendlin5 years agoSuper User
Yes, this goes in the advanced editor. Same for the header (as shown in the example)
When you get the data back from the POST call you need to parse it as needed. Again this is done in the same Advanced editor.