How to send the POST request in a PowerQuery?

When working with the PowerBI, you can easily consume the data from the REST service by using a Web connector. The problem with this is that the GET Http method is automatically used for this purpose. That is logical, because PowerBI should consume the data (GET) and not do some updates.

Unfortunately in the real life, services are more complex than just getting weather data or similar. I have in my projects very often very complex queries. That means that such queries in a REST service can only be designed by using the POST Http method, which is NOT supported by the PowerBI designer.
The good news is that you can send POST request, but in the Power Query only.

Following code snippet shows the complex query of an enterprise service that requires the query in the body of the POST request and ApiKey authentication in the header.


SvcUrl = "https://****",

ApiKey = "*****",

Content = "
  ""Tenant"": daenet"",
  ""filter"": {
    ""fields"": [
        ""fieldName"": ""Field1"",
        ""operator"": 0,
        ""argument"": [
        ""distinct"": false
  ""fields"": [
    ""ProjectedField1"",""ProjectedField2"", ""EngTyp"", ""Name""
  ""top"": 100,
  ""skip"": 0,
  ""language"": ""001""

Response= Web.Contents(SvcUrl, 

Headers=[ApiKey=ApiKey, #"Content-Type" = "application/json"]

Json = Json.Document(Response)



Hope this helps.

comments powered by Disqus