Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
short:
I am looking to maintain and use tokens recieved in one query, to be used in all other subsequent queries.
long:
I am a REST api developer, and I have an increase in customers that want to import data into Power Bi. Unfortunately, our access tokens are relatively short lived, and I did not want the end-user (usually not very code-savy) to have to work and renew this token themselves and store this data in a static parameter.
I've tried storing the data in existing parameters, but those values do not change from the default in subsequent queries. I've also tried with local parameters in a query, but these parameters do not exist in future queries. A method that comes closest is this pseudocode:
<Query>
--AuthBody--
apiKey = restapiurl/getapikey?key=secret
accessKey = restapiurl/getaccesskey [HEADER apitoken = apiKey]
--End AuthBody--
Source = resapiurl/getreportdata [HEADER apitoken = apiKey, useraccess=accessKey]
</Query>
The problem with this method is that authorization calls have to be made for every single data query.
I'm just looking for a more efficient method where the apiKey and accessKey values can be set once (and updated upon refresh), then used for other queries.
Thanks.
Sorry, no idea on this.
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.