0

I want to get a file(xlsx) from a URL, which is in a Sharepoint folder.

url = 'http://www.sharepointexampleurl.com'
username='username'
password='password'         
response = requests.get(url, auth=(username, password), headers={'Connection': 'close'})
if response.status_code >= 300:
    raise osv.except_osv(_('Error'), _('Bad Request'))

I always get a 403 error. Do I have to use sharepoint library?I can get files from URLs without authentication, but with authentication i can't. Any ideas?

pankar
  • 123
  • 1
  • 5
  • 14
  • Have you checked http://stackoverflow.com/questions/395451/how-to-download-a-file-over-http-with-authorization-in-python-3-0-working-aroun ? – hilcharge Oct 02 '15 at 15:17
  • What kind of authentication are you expecting? Your example uses basic authentication, which may not be appropriate for the site. Here is list of common types: http://docs.python-requests.org/en/v2.0-0/user/authentication/ – hilcharge Oct 02 '15 at 15:33
  • I don't know which authentication is the proper one for Sharepoint.That's why I asked the question. – pankar Oct 05 '15 at 12:45
  • Sharepoint supports many forms of authentication. [Auth details for sharepoint 2013](https://technet.microsoft.com/en-us/library/cc262350.aspx). The site admins may have one or many options configured. Ask the site admins what they use. Otherwise try them all. – hilcharge Oct 05 '15 at 14:29

1 Answers1

0
site = "http://www.sharepointexampleurl.com"
username = "username"
password = "password"
response = requests.get(site, auth=HttpNtlmAuth(username, password))
print(response.status_code)