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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
shivam_dalvi
Regular Visitor

Microsoft fabric notebook - to execute notebook externally using rest api

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.

https://learn.microsoft.com/en-us/rest/api/fabric/core/job-scheduler/run-on-demand-item-job?tabs=HTT...

 

Is there a way to integrate a token refresh mechanism into our API calls to ensure continuous access?

1 ACCEPTED SOLUTION
Expiscornovus
Super User
Super User

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:

https://learn.microsoft.com/en-us/rest/api/fabric/articles/get-started/fabric-api-quickstart#c-code-...

 

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?

 

 

 



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

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:

vyohuamsft_0-1730946916837.png

 

How to use Continuous Access Evaluation enabled APIs in your applications - Microsoft identity platf...

 

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.

Expiscornovus
Super User
Super User

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:

https://learn.microsoft.com/en-us/rest/api/fabric/articles/get-started/fabric-api-quickstart#c-code-...

 

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?

 

 

 



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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