Package: sharepoint-too
SharePoint TooAuthor:Tim Santortsantor@xstudios.agencyOverviewThis module will handle authentication for your SharePoint Online/O365 site, allowing you to make straightforward HTTP requests from Python. It extends the commonly used Requests module, meaning that returned objects are familliar, easy to work with and well documented. Leveragesrequests_ntlmfor authentication.Inspired bySharepywhich seems to no longer be maintained.NOTE:Currently handles dealing with SharePoint Lists via handy shortcut methods, but you can currently also callsp.get(url, *args, **kwargs)andsp.post(url, *args, **kwargs)with manually assembled SharePoint REST URLs and it will work.InstallationSharePoint Too can be installed from the Python Package Index, PyPI.pip install sharepoint-tooInitiate a SharePoint sessionfrom sharepoint_too import SharePointSession
sp = SharePointSession("example.sharepoint.com")Make an API callr = sp.get_lists()This will return a Requestsresponseobject. See therequests documentationfor details. By default, the headersaccept: application/json;odata=verboseandcontent-type: application/json;odata=verboseare sent with all requests, so API responses will be formatted as JSON where available.Headers can be added or overridden by supplying a dictionary to the relevant method:r = sp.get_lists(headers={"Accept": "application/atom+xml"})Currently thepost()method will send ax-requestdigestheader, allowing modifications to be made to SharePoint objects.Other available methodssp.get_list_metadata(weblist_url, list_guid=None, list_title=None)
sp.get_list_entity_type(weblist_url, list_guid=None, list_title=None)
sp.get_list_items(weblist_url, list_guid=None, list_title=None)
sp.get_list_item(weblist_url, item_id, list_guid=None, list_title=None)
sp.add_list_item(weblist_url, payload, list_guid=None, list_title=None)
sp.update_list_item(weblist_url, item_id, data, list_guid=None, list_title=None)
sp.upload(weblist_url, item_id, filename, list_guid=None, list_title=None)
sp.delete_list_item(weblist_url, item_id, list_guid=None, list_title=None)NOTE:Onlylist_guidorlist_titleneed to be supplied, not both.TestsSince the tests require a SharePoint account you'll need to supply private values in order to run the tests:Create a file called~/sharepoint_too/config.cfg:[default]
domain=
user=
pwd=
site_url=https://example.sharepoint.com
weblist_url=https://example.sharepoint.com/_api/web/lists
list_title=
list_guid=
list_item_type=Now you can run:python -m pytest tests/test_sharepoint_too.pyDocumentationDocumentation is available at TODORequirementsrequestsrequests_ntlmIssuesIf you experience any issues, please create anissueon Bitbucket.HistoryAll notable changes to this project will be documented in this file. This project adheres toSemantic Versioning.0.1.0 (2020-04-27)First release on PyPI.0.1.1 (2020-04-27)Updated license and installaton instructions due to typo.0.1.2 (2020-06-08)When uploading a file to SharePoint we use just the filename and not the full file path.0.2.0 (2021-09-23)Changed: Now you must pass on open file as content along with desired filename. We can't assume the file is local, it may be local or in the cloud. Such as with Django storages.