[Python] How to access a sharepoint site via the REST API in Python?

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following site in SharePoint 2013 in my local VM:

    http://win-5a8pp4v402g/sharepoint_test/site_1/

    When I access this from the browser, it prompts me for the username and password and then works fine. However I am trying to do the same using the REST API in Python. I am using the requests library, and this is what I have done:

    import requests
    from requests.auth import HTTPBasicAuth


    USERNAME = "Administrator"

    PASSWORD = "password"

    response = requests.get("http://win-5a8pp4v402g/sharepoint_test/site_1/", auth=HTTPBasicAuth(USERNAME, PASSWORD))

    print response.status_code


    However I get a 401. I dont understand. What am I missing?

    Note: I followed this article http://tech.bool.se/using-python-to-request-data-from-sharepoint-via-rest/

    Continue reading...

Compartilhe esta Página