I try to upload a small text file on SharePoint with Python requests :

from requests_ntlm import HttpNtlmAuth
import requests
with open(logFile, 'rb') as fd :
    r = requests.post(url,
                      files={'file': (logFile, fd)},
    print(r.url, r, r.headers)
with open(logFile, 'rb') as fd :

I get correct answer 200 from request but my file is not on SharePoint :

<Response [200]>
{'Cache-Control': 'private, max-age=0', 'Content-Type': 'text/html; charset=utf-8', 'Content-Encoding': 'gzip', 'Expires': 'Sun, 23 Dec 2018 15:19:43 GMT', 'Last-Modified': 'Mon, 07 Jan 2019 15:19:43 GMT', 'Vary': 'Accept-Encoding', 'Server': 'Microsoft-IIS/8.5', 'X-SharePointHealthScore': '0', 'X-AspNet-Version': '4.0.30319', 'SPRequestGuid': '2cb1b39e-2364-109a-4475-3bf486ec2f9f', 'request-id': '2cb1b39e-2364-109a-4475-3bf486ec2f9f', 'X-FRAME-OPTIONS': 'SAMEORIGIN', 'SPRequestDuration': '106', 'SPIisLatency': '0', 'X-Powered-By': 'ASP.NET', 'MicrosoftSharePointTeamServices': '', 'X-Content-Type-Options': 'nosniff', 'X-MS-InvokeApp': '1; RequireReadOnly', 'Date': 'Mon, 07 Jan 2019 15:19:43 GMT', 'Content-Length': '35311'}
b'\r\nRunning test 2 : C++\r\n 1  : \r\n'

If I try to read (requests.get) or delete a file from SharePoint it works. Any hint ? Thanks !

  • Did you get the solution regarding above problem, please let me know the answer if you know the answer thanks Pavan kancharala – Naga Pavan Mar 11 at 12:40
  • No I did not. I even got administrator right on the share point but result was the same, so it should not be an access right issue... – Chris Mar 12 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.