【问题标题】:Communication between PowerBI and REST APIPowerBI 和 REST API 之间的通信
【发布时间】:2022-01-22 20:11:26
【问题描述】:

我目前正在努力让 PowerBI 与 REST API 正确通信。

REST API 由我开发,具有常见的 GET 请求,可以在 PowerBI 上正常工作,但我也有一些 POST 请求,我希望根据 PowerBI 过滤器填充 POST 请求的正文 (JSON)。

API 端点是一个抽象的例子

POST /api/events

请求正文看起来像

{
    "startDateTime": "2021-12-21T10:48:06.595Z",
    "endDateTime": "2021-12-21T10:48:06.595Z",
    "eventLocations": [
        {
            "country": "USA",
            "state": "California",
            "city": "Los Angeles"
        },
        {
            "country": "Germany",
            "state": "Bavaria",
            "city": "Munich"
        }
    ]
}

数组eventLocations 必须根据在 PowerBI 过滤器中选择的值增大或缩小,其中一些值用于开始日期和结束日期。

我可以在 PowerBI 中使用此查询静态请求数据:

let
url = ".../api/events",
headers = [#"Content-Type" = "application/json", #"Accept" = "application/json"],
postData = "{
    ""startDateTime"": ""2021-12-21T10:48:06.595Z"",
    ""endDateTime"": ""2021-12-21T10:48:06.595Z"",
    ""eventLocations"": [
        {
            ""country"": ""USA"",
            ""state"": ""California"",
            ""city"": ""Los Angeles""
        },
        {
            ""country"": ""Germany"",
            ""state"": ""Bavaria"",
            ""city"": ""Munich""
        }
    ]
}",
response = Web.Contents(
url,
    [
    Headers = headers,
    Content = Text.ToBinary(postData)
    ]
),
jsonResponse = Json.Document(response)
in
jsonResponse

如何使这个请求动态过滤/用户输入? 有没有更好的方法从 PowerBI 与 REST 通信?

【问题讨论】:

  • 使用Python 连接器

标签: rest powerbi


【解决方案1】:

根据我使用 power bi 的经验,通常最好导入用户需要的所有数据,并按计划随着时间的推移添加数据。让用户与 power bi 交互并根据这些交互动态地将查询发送到 api 可能是不可能的。这种架构将是“直接查询”,Python 和 Web 连接器都不支持直接查询。

https://docs.microsoft.com/en-us/power-bi/connect-data/power-bi-data-sources

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 2021-03-24
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 2021-07-15
    • 2020-07-31
    相关资源
    最近更新 更多