Secret Power Of Web.Contents PQ Function: Options[Content] Parameter – Part 5

GET and POST method using Power query

I am sure you have rarely used this or know about this. Yes, You can use the POST HTTP method using Web.Contents. We can only use the GET and POST method using Power query. Other REST API method(PUT,DELETE,PATCH,UPDATE etc) is not possible. And this post is about the POST Method.


We are going to discuss the Content option in this post. Content is basically the body of the POST Method. Whatever you specify in the Content will be used as a body.

Here is a sample code.

Content Param/Post Method Example.pq Code:

let
  JSONBody = "{""name"": ""Md.Ismail Hosen""}", 
  Source = Web.Contents(
    "https://postman-rest-api-learner.glitch.me/info", 
    [
      Content = Text.ToBinary(JSONBody), 
      Headers = [Accept = "*/*", #"Content-Type" = "application/json"]
    ]
  ), 
  ConvertedToTable = fxJsonBinaryToTable(Source, true, ".")
in
  ConvertedToTable

As a body, I have used the JSONBody step here. I want you to look into the Content field. If you look carefully then you will find that we are using Text.ToBinary to convert body json to a binary format. So make sure you use Text.ToBinary when you want to use the Content option.

Here is the sample output of that API Call:

Sample Output Of Post Method

Leave a Reply

Subscribe to Blog via Email

Enter your email to subscribe to this blog and receive notifications of new posts by email.

You may also like

Please login to Continue Reading