Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Team,
While calling a notebook received an error below
{
"requestId": "<requestId_value>",
"errorCode": "RequestFailed",
"message": "Unable to process the request"
}
so to avoid this we need to use token, as per the documentation below we used Bearer Token generated here and tested the same in postman and it's able to give 202 which allows to execute the notebook.
Is there a way to integrate a token refresh mechanism into our API calls to ensure continuous access?
Solved! Go to Solution.
Hi @shivam_dalvi,
Below is an example with C# to acquire the access token, you might be able to adapt that to Python/PySpark code in your Fabric Notebook:
Here is another example how in concept this should work:
https://stackoverflow.com/questions/75751477/how-to-get-a-microsoft-azure-authorization-token
Hope this helps to get you started?
Hi, @shivam_dalvi
At the time of initial authentication, a refresh token and an access token are requested. This refresh token can be used to obtain a new access token when the current access token expires. Make sure your authentication request includes a offline_access scope to receive the refresh token. You can check the following link:
Implementing the Refresh Token Flow
You might also consider using libraries such as the Microsoft Authentication Library (MSAL), which can handle token acquisition and refresh automatically. You can refer to these links:
Continuous access evaluation in Microsoft Entra - Microsoft Entra ID | Microsoft Learn
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @shivam_dalvi,
Below is an example with C# to acquire the access token, you might be able to adapt that to Python/PySpark code in your Fabric Notebook:
Here is another example how in concept this should work:
https://stackoverflow.com/questions/75751477/how-to-get-a-microsoft-azure-authorization-token
Hope this helps to get you started?
hey hi @Expiscornovus, even if we use the AAD to get tokens for requesting the api but in response what if we want to understand whether the notebook triggered is in progress, completed or failed?. As of now the response is either 202 Accepted or if there's any error, instead can we get jobInstanceId so that we can track the status of the job using the below api mentioned in doc https://learn.microsoft.com/en-us/rest/api/fabric/core/job-scheduler/get-item-job-instance?tabs=HTTP
You can use GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}/jobs/instances/ to see status of job, request to this url if you are running notebook, every 30 second you can check status in the return response value