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
niculcig
New Member

API Call POST Method - Power Query - Syntax Help

Hello and good day everyone,

 

I've been trying for 3 days to connect to an API using Post Method. I been using different methods that I found on some forums but still I can't get the correct result.

 

This is what I got: 

 

-URLhttps://e-api.gemius.com/api/markets

-Authentication Token : Bearer XXXXX
-JSON response from postman: 

[{"id":2,"iso":"be","name":"Belgium"}]
-Example request from the documentation:
curl -H 'Authorization: Bearer __TOKEN__' -H 'Content-Type: application/json' -X POST 'https://eapi.
gemius.com/api/markets'
 
I tried this with Power Query with no success :
 

let
AuthKey = "Bearer XXX",
url = "https://e-api.gemius.com/api/markets",
body = {id="2", iso="be", name="be"},
Source = Json.Document(Web.Contents(url,[
Headers = [#"Authorization"=AuthKey ,
#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
))
in
Source

 

I don't have a lot of experience working with API's if someone can help me it would be wonderfull.

 

Thx!

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @niculcig ,

the Power BI /Power Query /M-syntax to create a record or a list is quite the opposite of how you do it in JSON.

So step
body = {id="2", iso="be", name="be"},

in your query is not valid.

To create this record in M, you have to use square brackets instead:

body = [id="2", iso="be", name="be"]

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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