Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
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?
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:
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 🙂