Forum Discussion

Nytar's avatar
Nytar
Frequent Visitor
2 years ago
Solved

How to List and Execute Notebooks in Microsoft Fabric?

Hi, I'm using Microsoft Fabric and need help managing notebooks in my workspace. Specifically: How to list notebooks stored in various directories? How to execute these notebooks from a central n...
  • Anonymous's avatar
    Anonymous
    2 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 Team

     

    If 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!