Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello. I am calling an API to get data into Power BI but am facing an issue that my authorization token expires for the API before the query completes. The JWT Token used for authentication is set to expire every 10 minutes. There is an API URL that can be called to extend the session for the existing token but I am new to M so I do not know how to track the execution time of the query and call that URL before the 10 minute mark is reached.
Would appreaciate any help and am here if more details are required to provide an answer.
Solved! Go to Solution.
You could track the start time of the query and then compare it to the current time. If the difference between the start time and current time is greater than 10 minutes, you could make a call to the API URL to extend the session with a new token before continuing with the query.
Here's some sample code in M language to accomplish this:
let startTime = DateTime.LocalNow(), result = #"Your data source query", currentTime = DateTime.LocalNow(), timeDiff = currentTime - startTime, renewToken = if timeDiff > #duration(0, 10, 0, 0) then // code to renew token here else null in result
You could track the start time of the query and then compare it to the current time. If the difference between the start time and current time is greater than 10 minutes, you could make a call to the API URL to extend the session with a new token before continuing with the query.
Here's some sample code in M language to accomplish this:
let startTime = DateTime.LocalNow(), result = #"Your data source query", currentTime = DateTime.LocalNow(), timeDiff = currentTime - startTime, renewToken = if timeDiff > #duration(0, 10, 0, 0) then // code to renew token here else null in result
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
13 | |
9 | |
7 | |
6 |