Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i use sharepoint (via soap?) from python?

I want to use Sharepoint with python (C-Python)

Has anyone tried this before ?

like image 723
Blauohr Avatar asked Oct 20 '08 16:10

Blauohr


People also ask

Is it possible to access a SharePoint site in Python?

For Organisation restricted Sharepoint sites that are hosted on a Company's intranet, I haven't tested this code out. You will have to modify the link to the Sharepoint file a bit since you cannot directly access a Sharepoint file in Python using the URL address of that file which is copied from the web browser.

What is SOAP API in Python?

SOAP stands for Simple Object Access Protocol, as the name suggests nothing but a protocol for exchanging structured data between nodes. It uses XML instead of JSON. In this article, we are going to see how to make SOAP API calls using python.

How to get the SharePoint access token in Python?

The config you need are: a client id, client secret, resource id, and SharePoint ID. This is the structure of the request I am using to get the access token: So I created a utility function in Python to make the request for the SharePoint token, based on the CURL request:

How to read SharePoint file contents with Python?

Read SharePoint file contents with Python Below is a simple script in which I use the Python requests library to query SharePoint using the "Retrieve a file that is attached to that list item" query, providing the access token in the headers. The key is that we want the response to be in bytes.


1 Answers

I suspect that since this question was answered the SUDS library has been updated to take care of the required authentication itself. After jumping through various hoops, I found this to do the trick:


from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated


user = r'SERVER\user'
password = "yourpassword"
url = "http://sharepointserver/_vti_bin/SiteData.asmx?WSDL"


ntlm = WindowsHttpAuthenticated(username = user, password = password)
client = Client(url, transport=ntlm)

like image 171
somewhatoff Avatar answered Oct 26 '22 14:10

somewhatoff