Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AlfredQuick
Frequent Visitor

Cómo realizar una solicitud GET o POST en Power Query (datos públicos)

Hola amigos,


Estoy tratando de obtener información en Power BI desde un servicio web que ofrece diferentes posibilidades para la solicitud, SOAP GET y POST:

https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?op=Consulta_DNPRC

En ese vínculo, puede ver un ejemplo de cada tipo de solicitud, por ejemplo, para una solicitud GET, el ejemplo es:

GET /ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/Consulta_DNPRC? Provincia-cadena&Municipio-cadena&RC-cadenaHTTP/1.1
Host: ovc.catastro.meh.es


Se trata de datos públicos, por lo que no hay problemas con la autenticación. ¿Cómo puedo hacer esto en Power Query? Necesito usar la última cadena (RC) las otras son opcionales. Si necesita más información por favor no dude en pedirme por ella.

Muchas gracias por la ayuda,

Alfred

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Las solicitudes GET se realizan llamando a Web.Contents sin un parámetro Content, las solicitudes POST se realizan llamando a Web.Contents con el parámetro.

Obtener:

let
    URL = "http://xxx/tstat",
    headers = [#"Content-Type"="application/json"],
    web = Web.Contents(URL, [ Headers = headers, ManualStatusHandling = {404, 400}]),
    result = Json.Document(web),
...

Exponer:

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

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Esto no está funcionando para mí. Estoy intentando ejecutar una API POST sin parámetros. Por favor, ayuda si no hay otras soluciones.

Syndicate_Admin
Administrator
Administrator

Consulte también https://community.fabric.microsoft.com/t5/Desktop/How-to-run-POST-request-in-M/m-p/457138 para otro código que agregue el parámetro Contenido con vacío a la llamada Web.Contents para forzar que Power BI realice una solicitud POST

Content=Text.ToBinary("")

AlfredQuick
Frequent Visitor

Muchas gracias @lbendlin

lbendlin
Super User
Super User

Las solicitudes GET se realizan llamando a Web.Contents sin un parámetro Content, las solicitudes POST se realizan llamando a Web.Contents con el parámetro.

Obtener:

let
    URL = "http://xxx/tstat",
    headers = [#"Content-Type"="application/json"],
    web = Web.Contents(URL, [ Headers = headers, ManualStatusHandling = {404, 400}]),
    result = Json.Document(web),
...

Exponer:

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.