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/OVCSWLocalizacionRC/OVCCallejero.asmx?op=Consulta_DNPRC

In that link, you can see an example of each request type, for example for a GET request the example is:

GET /ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/Consulta_DNPRC?Provincia=string&Municipio=string&RC=string HTTP/1.1
Host: ovc.catastro.meh.es

 
This is public data, so no problems with authentication.How can I do this in Power Query? I need to use the last string (RC) the other ones are optional. If you need anymore info please don't hesitate to ask me for it.

 

Thanks a lot for the help,

Alfred

  • 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),
    ...
    

4 Replies

  • 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),
    ...