Forum Discussion
REST API authentication via post/cookie
Disclaimer: I've never used a REST API as a PowerBI datasource before. My experience is limited to SQL and CSV. I'm a noob.
I have a standard JSON-based REST API that I want to use as a datasource. The problem I have is that authentication requires a username and password to be posted to a index.html page as form data, which is validated and a cookie with a sessionID is returned/created to be used to authenticate future API calls. I've tested it in Postman and can get it to work easily (even for someone as inexperienced as me):
1. Set the request method to POST.
2. Enter the URL (https://[hostname]:[port]/login.html)
3. Set a Content-Type headerwith the value application/x-www-form-urlencoded
4. In the body, create a key for username and password with the appropriate values
5. Send the request and a cookie with a sessionID is returned
I just have no idea how to do this in PowerBI. I've done quite a bit of hunting through this community and tried to adapt some likely solutions but haven't had any luck yet. If anyone is able to point me in the right direction, I'd really appreciate it.
9 Replies
- amitchandakSuper User
Anonymous , check this old power query blog- if that cab help https://eriksvensen.wordpress.com/2014/09/15/specifying-json-query-in-power-query-example-statistics-sweden/
- AnonymousNot applicable
Thanks a lot, amitchandak. It doesn't help in this case unfortunately, but it's a great reference which I've bookmarked.
- v-xulin-mstfCommunity Support
Hi Anonymous
Please refer this:
https://www.sqlshack.com/importing-data-from-json-files-and-power-bi-rest-apis-into-power-bi/
Detailed steps on how to import REST API data sources are described here.
Best Regards,
LinkIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Thanks very much, v-xulin-mstf, Unfoirtunately, this doesn't cover authentication, but it's an excellent introduction to using a REST API as a datasource. I appreciate that.
- v-xulin-mstfCommunity Support
Hi Anonymous ,
You can refer the following posts:
https://community.powerbi.com/t5/Power-Query/Saving-Cookies-from-POST-Request-to-Rest-API/m-p/957172
https://community.powerbi.com/t5/Developer/Failed-to-get-API-authentication-by-Postman/td-p/1855644
https://community.powerbi.com/t5/Developer/REST-API-Silent-Authentication-Token/td-p/156004
Hope it helps!😉
Best Regards,
LinkIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- v-xulin-mstfCommunity Support
Hi Anonymous,
Is your issue solved?
If the issue has been solved, please share the solution and adopt it to help others.
Thanks! 😉
Best Regards,
LinkIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- DHCookTechFrequent Visitor
Hello Anonymous ! Were you able to find a way to do this? I am running into the exact same situation.
- fatimaimrann123New Memberhello did u figure out??
- fatimaimrann123New Memberhello did u figure out??