Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Markzolotoy
Impactful Individual
Impactful Individual

POST body is not working

I am spending a lot of time trying to get POST's body being actually sent to the server.

API call:

 

Response  = Json.Document(Web.Contents(api_url,
     [ 
        Headers = [#"Content-Type"="application/json"],
        Content=Text.ToBinary(body)
     ] 
   )
)

 

Body. Code is a bit simplified...

Version 1.

 

body = "{""client_id"": ""xxxxxx"",  ""username"": ""bba85b3d-5121-4439-8f3f-4c1a644bea5f"",  
""client_secret"": ""xxxxxxxxxxxxxxxxxxx"", ""grant_type"": ""password""}",

 

No parameters on the server.

Version 2.

 

client_id = "xxxxxxx",
username = "bf083798-8751-446e-9c60-6c1cd36ad632",
client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
grant_type = "password",
body = Text.ToBinary("client_id" & ":" & client_id & ",username" & ":" & username & ",client_secret" & ":" & client_secret & ",grant_type" & ":" & grant_type),

 

No parameters on the server.

Verion 3.

 

body = [client_id="xxxxxxx",username="bf083798-8751-446e-9c60-6c1cd36ad632",client_secret="xxxxxxxxxxxxxxxxxxx",grant_type="password"],
Json = Json.FromValue({body}),
Response  = Json.Document(Web.Contents(api_url,
    [ 
      Headers = [#"Content-Type"="application/json"],
      Content=Json
    ] 
    )
    )

 

No parameters on the server.

 

Version 4, the working one.

 

body = [client_id="xxxxxx",username="bf083798-8751-446e-9c60-6c1cd36ad632",client_secret="xxxxxxxxxxxxxxx",grant_type="password"],
body = Uri.BuildQueryString(body),

 

Correct parameters appear on the server.

My problem with working version is that it is a QueryString and I am not sure whether it is encrypted or not.

 

Thanks

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Markzolotoy 

I'm not sure what the actual problem is. The title says the POST body isn't working but you've provided an example where it is.

Uri.BuildQueryString does not do encryption.  But aren't you then using Text.ToBinary() to encode the output from Uri.BuildQueryString.  So it isn't encrypted really, but it is encoded.   Your making POST requests not GET so your request isn't providing a 'query string' in the usual sense of HTTP.

What are your privacy concerns?  I thought you were working with an internal API?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @Markzolotoy 

I'm not sure what the actual problem is. The title says the POST body isn't working but you've provided an example where it is.

Uri.BuildQueryString does not do encryption.  But aren't you then using Text.ToBinary() to encode the output from Uri.BuildQueryString.  So it isn't encrypted really, but it is encoded.   Your making POST requests not GET so your request isn't providing a 'query string' in the usual sense of HTTP.

What are your privacy concerns?  I thought you were working with an internal API?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Yes, I am working with internal APIs, but once I publish it it will go over the wire. So far as you explained it is still a part of the POST's body, should be ok then.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.