Forum Discussion

Jeanxyz's avatar
Jeanxyz
Icon for Power Participant rankPower Participant
1 year ago
Solved

Does anyone knows how to run a http call in a notebook

I am reading a MS documentation, it says one can refresh sql endpoint meta data via a http call: POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/sqlEndpoints/{sqlEndpointId}/refres...
  • OnurOz's avatar
    1 year ago

    Hi Jeanxyz,

     

    You can run HTTP calls directly from a notebook in Microsoft Fabric using Python, and it's straightforward if you use the popular requests library. This approach works in both Spark and non-Spark Python environments.

     

    import requests
    
    url = "https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/sqlEndpoints/{sqlEndpointId}/refreshMetadata"
    headers = {
        "Authorization": "Bearer YOUR_ACCESS_TOKEN"
    }
    
    response = requests.post(url, headers=headers)
    print(response.status_code)
    print(response.text)

     

    Replace {workspaceId}, {sqlEndpointId}, and YOUR_ACCESS_TOKEN with your actual values. You must provide a valid Azure AD access token, this usually involves authentication, which can be handled via Azure Identity, MSAL, or other SDKs that you may already use for automation.

     

    Hope that helps

    Onur


    😊If this post helped you, feel free to give it some Kudos! 👍

    ✅And if it answered your question, please mark it as the accepted solution.