Python 3 script to upload files to sharepoint 2010

boukaka
boukaka used Ask the Experts™
on
I need a python 3 script to upload files to sharepoint 2010. I can't find anything that works because apparently REST api doesn't work for 2010.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Commented:
Did you try the WEBDAV route?

Author

Commented:
I'm looking at that but I can't seem to find any examples where it interacts with a sharepoint server. I'm looking for an example script to start from, do you know of one? I'm fairly new to Python.
nociSoftware Engineer
Distinguished Expert 2018

Commented:
Pypi is a nice source to look around:   https://pypi.org/project/webdavclient/
There also is a sharepoint access module, not sure it that uses the REST Api though.   https://pypi.org/project/sharepoint/
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Author

Commented:
I have found a Powershell solution that works - I wish it was in python - does anyone know how to convert this?

# Set the variables
$destination = "http://portal.contoso.com/sites/stuff/Docs” 
$File = get-childitem “C:\Docs\stuff\Secret Sauce.docx”

# Since we’re doing this remotely, we need to authenticate
$securePasssword = ConvertTo-SecureString "pass@word1" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ("contoso\johnsmith", $securePasssword)

# Upload the file
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = $credentials
$webclient.UploadFile($destination + "/" + $File.Name, "PUT", $File.FullName)
Software Engineer
Distinguished Expert 2018
Commented:

Author

Commented:
Fantastic, thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial