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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Shamatix
Post Partisan
Post Partisan

Rest API Access

Hey fellow users of Power Bi,

 

I need to generate an API key ever 60min when I want to use this api.

In order to generate the API key I need to throw a POST after https://XXXXXXXXXXXXX.com/oauth2/token and I need to fill out an email and a password in the Body along with setting a header named Content-Type to application/x-www-form-urlencoded

 

Header:
Content-Type = application/x-www-form-urlencoded

 

Body:

email = xxxx@xxxxxx.com

password = xxxxxxx

 

How can I do this in the advanced editor?
I have looked at a couple of different examples but I havnt been able to do this successfully yet.

 

Best regards

 

4 REPLIES 4
v-yuta-msft
Community Support
Community Support

@Shamatix ,

 

You can create a new blank query and use Web.Contents(). 

 

Reference:

https://docs.microsoft.com/en-us/powerquery-m/web-contents

https://docs.microsoft.com/en-us/power-query/web.contents

 

Community Support Team _ Jimmy Tao

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

I just dont get how I specify the body, I have seen countless examples of the header, but whenever I try to implement the body it goes wrong :S?

@Shamatix ,

 

You may refer to this similar thread: https://community.powerbi.com/t5/Integrations-with-Files-and/Dataset-Refresh-REST-API-amp-JSON-with-....

 

Community Support Team _ Jimmy Tao

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


@v-yuta-msft wrote:

@Shamatix ,

 

You may refer to this similar thread: https://community.powerbi.com/t5/Integrations-with-Files-and/Dataset-Refresh-REST-API-amp-JSON-with-....

 

Community Support Team _ Jimmy Tao

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


 

Hey there,

 

I have gotten a bit further as follows:


let
Source = Json.Document(Web.Contents("https://api.xxxxx.dk/oauth2/token",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(Uri.BuildQueryString([grant_type="password", client_id="XXXXXXXXXXXXXXXXXXXXX", client_secret="XXXXXXXXXXXXXXXXXX", email="XXXXX@XXXXX.com", password="XXXXXXX!"]))]))
in Source

 

However now I am getting the following error:

 

I spoke with the people who have made the API and they said they think "Json.Document" expects the return in json-format, however for /oauth2/token it is not as they are using the OAUTH standard. Can you help me make the above possible without the use of "Json.Document"?

Best regards 🙂

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors