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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Need some help calling API with body

so i have an API link to get data, it requires simply a post command with the api link and some body information

 

the body info is as followed:

SteffH_0-1681998018153.png

 

This works fine in Postman and I get the data in JSON format, but im curious how i can do the same in Power BI. Any help is appreciated 🙂

 

Also a second thing would be to make a script to receive the access token

 

It's a simple Post login link where the body is as follows:

SteffH_1-1681998127903.png

So the password and username and domain is given in the body, not in the authorization tab in Postman.

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

While the Power Query Web.Contents() function generates a GET request by default, you can make it generate a POST request by specifying the Content option.

vjianbolimsft_0-1683187701674.png

 

For more details, please refer to:

Web.Contents - PowerQuery M | Microsoft Learn 

Chris Webb's BI Blog: Web Services And POST Requests In Power Query 

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

While the Power Query Web.Contents() function generates a GET request by default, you can make it generate a POST request by specifying the Content option.

vjianbolimsft_0-1683187701674.png

 

For more details, please refer to:

Web.Contents - PowerQuery M | Microsoft Learn 

Chris Webb's BI Blog: Web Services And POST Requests In Power Query 

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I will use Datasets - Get Dataset In Group  API as an example:

let
//Get API Token
  tokenapiUrl = "https://login.microsoftonline.com/ecxxxxxxxx/oauth2/v2.0/token",
    body = [
          client_id="d32xxxxxx",
          grant_type="client_credentials",
          client_secret="vMfxxxxxx",
          scope="https://analysis.windows.net/powerbi/api/.default"
],

API_Response = Json.Document(Web.Contents(tokenapiUrl, [Headers = [Accept = "application/json"],
Content = Text.ToBinary(Uri.BuildQueryString(body))])),
token = API_Response[access_token],
//Get Data
apiUrl = "https://api.powerbi.com/v1.0/myorg/groups/476xxxxxxx/datasets/3a7xxxxxx",
data  = Json.Document(Web.Contents(apiUrl,[Headers=[#"Authorization"="Bearer "&token,#"Content-Type"="application/json"]]))
in
data

Final output:

vjianbolimsft_0-1683099657613.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi Jianboli,

 

First of all thanks for the detailed answer, however i think I'm running into one problem, the following things are given in the body of the getData call (not in the headers):

 

- access_token=

- version= (9.5 for example)

- images= (0 for example)

 

I'm dealing with a POST request, not a get request, and these parameters will not work when given as a header, but only when given in the body.

Anonymous
Not applicable

Any help is appreciated btw 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.