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
AlexisPREVOT
Resolver I
Resolver I

Convert CURL to PowerQuery

Good morning,

I would like to ask for your help because I am in the process of converting a curl API request to PowerQuery.
Here is the initial query : 

curl -X POST --data '{"dept": "75", "orange_area": ["O2A"], "output_format":"JSON"}' -H "X-LAPI-KEY: <YOUR KEY>" https://portal.ielo-liazo.com/lapi/v1/geomkt/siren/search

 

And here is my transformation into PowerQuery : 

let

LoginURL = "https://portal.ielo-liazo.com/lapi/v1/geomkt/siren/search",
PostBody = [#"data"="dept=75, output_format=JSON"],

Header = [#"X-LAPI-KEY"="YOUR KEY"],

PostBodyEncoded = Uri.BuildQueryString(PostBody),

Source = Json.Document(Web.Contents(LoginURL,[Content=Text.ToBinary(PostBodyEncoded),Headers=Header]))
in
Source

 

My problem is that I have an error telling me "Could not decode json".


How can I solve it ?
Thanks in advance

3 REPLIES 3
AlexisPREVOT
Resolver I
Resolver I

Thanks for the link I just looked at.
Now I have a new error message telling me that my 'dept' parameter is not found or invalid.

I don't know what to think or do about this request.

 

My new request : 

let
url = "https://portal.ielo-liazo.com/lapi/v1/geomkt/siren/search",
headers = [#"X-LAPI-KEY"="KEY"],
postData = Json.FromValue([#"data"="dept=75"]),
#"CSV importé" = Csv.Document(Web.Contents(url,[Content=(postData),Headers=headers]),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None])
in
#"CSV importé"

let
url = "https://portal.ielo-liazo.com/lapi/v1/geomkt/siren/search",
headers = [#"X-LAPI-KEY"="KEY"],
postData = Json.FromValue([dept=75,#"output_format"="JSON"]),
#"CSV importé" = Csv.Document(Web.Contents(url,[Content=(postData),Headers=headers]),[Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.None])
in
#"CSV importé"
lbendlin
Super User
Super User

Please read the documentation.  Example 2 Web.Contents - PowerQuery M | Microsoft Learn

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.