简体   繁体   中英

How to connect to Webservice REST with POST from Power BI

I am trying to connect to a webservice through Power BI but I still do not achieve result, first try to use the Web data source and with the Advanced Use add the Header that in my case is Content-Type and its value is application/json and additional as Body I have a token

在此处输入图像描述

Where I get as a result the following:

在此处输入图像描述

Additional also try to use as source "Blank Query", where I accessed the advanced editor section and add the following Query:

在此处输入图像描述

I get as an error the following:

在此处输入图像描述

To make sure that the Webservice works correctly and obtains a result I have used the Advanced REST Client tool and I have made the following configuration:

在此处输入图像描述

Where you can see that the Headers section I have added the Header name Content-Typ e and the value of the Header Value is application/json , in the Body section is where I have added the token

在此处输入图像描述

With this I realize that my Webservice gets an answer and that the service is working correctly, I would like someone to give me a little guidance in a short time to perform correctly

Supply the content to switch the method from GET to POST eg

Perform a POST against a URL, passing a binary JSON payload and parsing the response as JSON.

https://docs.microsoft.com/en-us/powerquery-m/web-contents#example-2

let
    url = "https://postman-echo.com/post",
    headers = [#"Content-Type" = "application/json"],
    postData = Json.FromValue([token = "abcdef"]),
    response = Web.Contents(
        url,
        [
            Headers = headers,
            Content = postData
        ]
    ),
    jsonResponse = Json.Document(response),
    json = jsonResponse[json]
in
    json

or

let
    url = "https://postman-echo.com/post",
    headers = [#"Content-Type" = "application/json"],
    postData = Text.ToBinary("{ ""token"":""abcdef""}"),
    response = Web.Contents(
        url,
        [
            Headers = headers,
            Content = postData
        ]
    ),
    jsonResponse = Json.Document(response),
    json = jsonResponse[json]
in
    json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM