I'm currently struggling with bringing PowerBI to properly communicate with a REST API.
The REST API is developed by me and has the common GET requests, which work fine with PowerBI, but I also have some POST requests where I want the body (JSON) of the POST request to be filled based on PowerBI filters.
An abstract example would be the API endpoint
POST /api/events
The request body looks like
{
"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"
}
]
}
The array eventLocations
must grow or shrink according to values selected in a PowerBI filter, some for the start and end date.
I can request the data statically with this query in 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
How would I make this request dynamic to filter/user inputs? And is there a better way to communicate with REST from PowerBI?
In my experience with power bi, it is usually best to import all the data the users need and add data over time on a schedule. Having user's interact with power bi and dynamically sending queries based on those interactions to an api is likely not possible. This architecture would be "Direct Query" and neither the Python nor the Web connectors support Direct Query.
https://docs.microsoft.com/en-us/power-bi/connect-data/power-bi-data-sources
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.