Forum Discussion
dinosainsburys
2 years agoHelper I
How do I send a POST Query using Power Query and extract the access token?
Hi, I am trying to figure out how to send a POST Query using Power Query but running into some issues. I have some code here which does not work, and did manage to get a 400 error but I have edit...
- 2 years ago
If you're trying to implement an OAuth2 authentication flow in Power Query you need to create a custom connector if you want to create something truly robust: https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-query-power-bi/
Uzi2019
2 years agoCommunity Champion
GET requests are done by calling Web.Contents without a Content parameter, POST requests are done by calling Web.Contents with the parameter.
GET:
let
URL = "http://xxx/tstat",
headers = [#"Content-Type"="application/json"],
web = Web.Contents(URL, [ Headers = headers, ManualStatusHandling = {404, 400}]),
result = Json.Document(web),
...
POST:
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),
...
- Uzi20192 years agoCommunity Champion
Hi dinosainsburys
You can also refer below post for reference
https://blog.crossjoin.co.uk/2014/04/19/web-services-and-post-requests-in-power-query/I hope I would resolved your issue!