Forum Discussion
AlfredQuick
5 years agoFrequent Visitor
How to make a GET or POST request in Power Query (public data)
Hello friends, I am trying to get info into Power BI from a web service that gives different possibilities for the request, SOAP GET and POST: https://ovc.catastro.meh.es/ovcservweb/OVCSWLocaliza...
- 5 years ago
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), ...
lbendlin
Super User
5 years agoGET 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),
...
Skabo_Wenco
3 years agoRegular Visitor
Also see https://community.fabric.microsoft.com/t5/Desktop/How-to-run-POST-request-in-M/m-p/457138 for another code adding the Content with empty parameter to Web.Contents call to force Power BI top make a POST request
Content=Text.ToBinary("")
- Anonymous3 years agoNot applicable
This is not working for me. I am trying run a POST API with no paramenters in. Please help if there is nay other solutions.