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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Obtain an API key from one query to use in another

Some of the REST API calls I make require that I use an API key (that has a short time to live).   I can call the query to get a new API key easily enough, but is there any way to save that key so that the other queries can use it?  I thought maybe putting it into a parameter that the other queries would then use but I cannot see a way to do that (even tried the new dynamic parameter preview but was unable to get that to work)

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

The dynamic parameter preview feature is only supported for some DirectQuery data sources. It cannot be applied in your scenario. 

 

As you can call the query to get a new API key, you can try using a query to get the key first and transforming the query to only return the key result (usually it is a text string). Then transform this query into a custom function. The result of the custom function is the key. In other queries, use this function to replace key string. As a result, when other queries need a key, they will call the custom function to query the key and get the result.

 

Here is an example which queries an access_token in a query and uses it in other queries then. The logic is similar. Have a try!

https://community.powerbi.com/t5/Power-Query/Channel-Advisor-API-Connection-with-auth-key-creation/td-p/2208091 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

lbendlin
Super User
Super User

You can only use variables inside a query/partition. Beware of the formula firewall monster.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.