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
Tess
Frequent Visitor

Send a POST request with -d in Power Query

Hi community,

 

I am trying to build a request in power query with this POST request

curl https://connect.squareup.com/v2/orders/search \
  -X POST \
  -H 'Square-Version: 2024-10-17' \
  -H 'Authorization: Bearer xxxxxxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "location_ids": [
      "xxxxxxxxxxx"
    ]
  }'

 I am struggling to construct a proper query in ower Query. The following M code returns an error MSG DataSource.Error: Web.Contents failed to get contents from 'https://connect.squareup.com/v2/orders/search ' (400): Bad Request.
------------------------------------

let
url="https://connect.squareup.com/v2/orders/search",
body = "{ ""location_ids"": ""xxxxxxxxxxx""}",
parsed_json = Json.Document(body),
buildQueryString = Uri.BuildQueryString(parsed_json),
headers=[
Authorization="Bearer xxxxxxxxxxxxx",
#"Content-Type"="application/json"],
Source = Json.Document(Web.Contents(url,[Headers = headers, Content = Text.ToBinary(buildQueryString) ] ))
in
Source

 

 

-----------------------
Can anyone help me out?

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

1 REPLY 1
lbendlin
Super User
Super User

Please follow the documentation. Use Json.FromValue. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-2

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors