The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have created a function in power query to get the authorization code which i will use to generate the access token to call the REST api. Here is the function definition -
() =>
let
body = "client_id=021ed4a0-7883-42fd-82c0-0566481cc851&response_type=code&redirect_uri=http://localhost:44300/&response_mode=query&scope=openid&state=12345",
Data= Json.Document(Web.Contents("https://login.microsoftonline.com/common/oauth2/authorize/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(body)
]))
in
Data
But when i am invoking this function i am getting this error
Can anybody tell me how to resolvre this one .
Hi @Amar-Agnihotri ,
I would try to call the API whithout instantly trying to convert the result to JSON like so:
let
body = "client_id=021ed4a0-7883-42fd-82c0-0566481cc851&response_type=code&redirect_uri=http://localhost:44300/&response_mode=query&scope=openid&state=12345",
Data= Web.Contents("https://login.microsoftonline.com/common/oauth2/authorize/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(body)
])
in
Data
This will allow you to check the format of the API return.
BTW: Your response parameter in the header suggests that you are getting a query back. That could explain the mismatch.
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
hi @ImkeF
I changed the code as you can see
But when i am invoking the function it is returning this -
I think this makes no sense .. No data ios returned
Yes, that's looking good.
Now, just click or doublecklick on the globe-symbol and the content should automatically extract further.
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
It seems the response result of the Web.Contents("https://login.microsoftonline.com...................) section is not a standard JSON type data, so this error appears when using Json.Document() to return the content. You can remove the "()=>" characters to convert it back into a common query and check its result.
Best Regards,
Community Support Team _ Jing
@v-jingzhang Hello,
Does this makes sense . I changed the code . It looks like this now -
How will it generate the auth code?