Forum Discussion

AlfredQuick's avatar
AlfredQuick
Frequent Visitor
5 years ago
Solved

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...
  • lbendlin's avatar
    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),
    ...