Forum Discussion
How to List and Execute Notebooks in Microsoft Fabric?
- Anonymous2 years ago
Hi Nytar ,
Thanks frithjof_v for your reply.
Please execute the following code in notebook:
import requests workspaceID = 'your_workspace_id' api_url = f'https://api.fabric.microsoft.com/v1/workspaces/{workspaceID}/notebooks' headers = { "Authorization": "Bearer your_token", "Content-Type": "application/json" } res = requests.get(api_url,headers=headers) note = res.json().get("value",[]) for note in note: if note['type'] == 'Notebook': print(note['displayName'])Replace workspaceid and your_token with your own.
The result of the execution is shown below, which lists all the notebooks in my workspace.
You can click on this official document for more information about it:
Items - List Notebooks - REST API (Notebook) | Microsoft Learn
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
1. Perhaps this will do the job, it also seems to list the notebooks in the workspace: https://fabric.guru/one-line-code-to-get-a-list-of-items-from-all-the-fabricpremium-workspaces
2. I think you can use some of the functions found here:
Edit: this blog shows how to achieve both 1. and 2.:
https://fabric.guru/using-runmultiple-to-orchastrate-notebook-execution-in-microsoft-fabric
To list all notebooks in the workspace:
import sempy.fabric as fabric
notebooks = fabric.list_items().query("Type == 'Notebook'")
notebooks