Please note that this question was originally asked on StackOverflow, as I didn't know StackExchange had a Sharepoint Q&A board until thoroughly researching an answer to this question. Feel free to vote to close the Stackoverflow duplicate.
Also, I'm using SharePoint through Office 365 (logging into the email and navigating from there to the SharePoint dashboard). I believe Tiago commented that this would be SharePoint v16.
- I have the URL for a SharePoint location:
https://company.sharepoint.com/(A). - Upon this, there's a site, at
https://company.sharepoint.com/sites/Web Projects(B).
All I'm trying to do is curl a file into B.
I've tried
curl -c cookies.txt --sslv3 --ntlm -u [email protected]:pass --upload-file hi.txt http://company.sharepoint.com/sites/Web Projects/hi.txt,- Every variation humanly imaginable of
cookies,sslv3,ntlmand--upload-fileparameters for thecurl, - Using
-kas a parameter, - Delimiting the space between
Web Projectsin the URL using both octal and hexadecimal encoding (040,%20). - Quadruple-checking the password and username combination!
None of these seem to work, or at least they don't anymore.
Annoyingly, downloading a file is a simple matter of curl --ntlm -u [email protected]:pass -O "https://company.sharepoint.com/Web Projects/Form1.cs".
Is there a way to upload a file to SharePoint from the command line?
EDIT:
As per some comment requests, here's a verbose output from the curl command. Note that the curl command parameters I'm using was scientifically selected by process of "that seems to be getting me the furthest".
Note that some information has been dubbed (such as replacing a few characters in the IP address with #'s) so I'm not posting anything I might regret:
With -k option
sudo curl -vvv --ntlm -u [email protected]:PASS --upload-file ~/hi.txt -k "https://company.sharepoint.com/Web%20Projects/hi.txt"
* Hostname was NOT found in DNS cache
* Trying 104.146.###.###...
* Connected to company.sharepoint.com (104.146.###.###) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES256-SHA384
* Server certificate:
* subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; OU=Microsoft Corporation; CN=*.sharepoint.com
* start date: 2016-02-23 19:42:10 GMT
* expire date: 2018-02-22 19:42:10 GMT
* issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT SSL SHA2
* SSL certificate verify ok.
* Server auth using NTLM with user '[email protected]'
> PUT /Web%20Projects/hi.txt HTTP/1.1
> Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
> User-Agent: curl/7.35.0
> Host: company.sharepoint.com
> Accept: */*
> Content-Length: 0
> Expect: 100-continue
>
< HTTP/1.1 401 Unauthorized
* Server Microsoft-IIS/8.5 is not blacklisted
< Server: Microsoft-IIS/8.5
< WWW-Authenticate: NTLM **base64 GIBBERISH REMOVED BECAUSE IT LOOKED LIKE SSL KEY**
< SPRequestGuid: 30fd909d-30c4-3000-1f64-de473aa63271
< request-id: 30fd909d-30c4-3000-1f64-de473aa63271
< Strict-Transport-Security: max-age=31536000
< X-FRAME-OPTIONS: SAMEORIGIN
< SPRequestDuration: 10
< SPIisLatency: 1
< X-Powered-By: ASP.NET
< MicrosoftSharePointTeamServices: 16.0.0.5423
< X-Content-Type-Options: nosniff
< X-MS-InvokeApp: 1; RequireReadOnly
< P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
< Date: Mon, 18 Jul 2016 10:56:14 GMT
< Content-Length: 0
<
* Connection #0 to host company.sharepoint.com left intact
* Issue another request to this URL: 'https://company.sharepoint.com/Web%20Projects/hi.txt'
* Found bundle for host company.sharepoint.com: 0x2117d00
* Re-using existing connection! (#0) with host company.sharepoint.com
* Connected to company.sharepoint.com (104.146.###.###) port 443 (#0)
* Server auth using NTLM with user '[email protected]'
> PUT /Web%20Projects/hi.txt HTTP/1.1
> Authorization: NTLM **base64 GIBBERISH REMOVED BECAUSE IT LOOKED LIKE SSL KEY**
> User-Agent: curl/7.35.0
> Host: company.sharepoint.com
> Accept: */*
> Content-Length: 0
> Expect: 100-continue
>
< HTTP/1.1 401 Unauthorized
* Server Microsoft-IIS/8.5 is not blacklisted
< Server: Microsoft-IIS/8.5
< SPRequestGuid: 30fd909d-20c6-3000-1f64-d2f727ac0347
< request-id: 30fd909d-20c6-3000-1f64-d2f727ac0347
< Strict-Transport-Security: max-age=31536000
< X-FRAME-OPTIONS: SAMEORIGIN
< SPRequestDuration: 17
< SPIisLatency: 1
* NTLM handshake rejected
* Authentication problem. Ignoring this.
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< MicrosoftSharePointTeamServices: 16.0.0.5423
< X-Content-Type-Options: nosniff
< X-MS-InvokeApp: 1; RequireReadOnly
< P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
< Date: Mon, 18 Jul 2016 10:56:16 GMT
< Content-Length: 0
* HTTP error before end of send, stop sending
<
* Closing connection 0
* SSLv3, TLS alert, Client hello (1):
Without -k option
sudo curl -vvv --ntlm -u [email protected] --upload-file ~/hi.txt "https://company.sharepoint.com/Web%20Projects/hi.txt"
Enter host password for user '[email protected]':
* Hostname was NOT found in DNS cache
* Trying 104.146.###.###...
* Connected to company.sharepoint.com (104.146.###.###) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES256-SHA384
* Server certificate:
* subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; OU=Microsoft Corporation; CN=*.sharepoint.com
* start date: 2016-02-23 19:42:10 GMT
* expire date: 2018-02-22 19:42:10 GMT
* subjectAltName: company.sharepoint.com matched
* issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT SSL SHA2
* SSL certificate verify ok.
* Server auth using NTLM with user '[email protected]'
> PUT /Web%20Projects/hi.txt HTTP/1.1
> Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
> User-Agent: curl/7.35.0
> Host: company.sharepoint.com
> Accept: */*
> Content-Length: 0
> Expect: 100-continue
>
< HTTP/1.1 401 Unauthorized
* Server Microsoft-IIS/8.5 is not blacklisted
< Server: Microsoft-IIS/8.5
< WWW-Authenticate: NTLM **base64 GIBBERISH REMOVED BECAUSE THIS LOOKED LIKE AN SSL KEY**
< SPRequestGuid: e3fc909d-2013-3000-1f64-d5aa6c556593
< request-id: e3fc909d-2013-3000-1f64-d5aa6c556593
< Strict-Transport-Security: max-age=31536000
< X-FRAME-OPTIONS: SAMEORIGIN
< SPRequestDuration: 9
< SPIisLatency: 2
< X-Powered-By: ASP.NET
< MicrosoftSharePointTeamServices: 16.0.0.5423
< X-Content-Type-Options: nosniff
< X-MS-InvokeApp: 1; RequireReadOnly
< P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
< Date: Mon, 18 Jul 2016 10:50:57 GMT
< Content-Length: 0
<
* Connection #0 to host company.sharepoint.com left intact
* Issue another request to this URL: 'https://company.sharepoint.com/Web%20Projects/hi.txt'
* Found bundle for host company.sharepoint.com: 0x832cf0
* Re-using existing connection! (#0) with host company.sharepoint.com
* Connected to company.sharepoint.com (104.146.###.###) port 443 (#0)
* Server auth using NTLM with user '[email protected]'
> PUT /Web%20Projects/hi.txt HTTP/1.1
> Authorization: NTLM **base64 GIBBERISH REMOVED BECAUSE THIS LOOKED LIKE AN SSL KEY**
> User-Agent: curl/7.35.0
> Host: company.sharepoint.com
> Accept: */*
> Content-Length: 0
> Expect: 100-continue
>
< HTTP/1.1 401 Unauthorized
* Server Microsoft-IIS/8.5 is not blacklisted
< Server: Microsoft-IIS/8.5
< SPRequestGuid: e3fc909d-2015-3000-1f64-d0e1cefbb2d4
< request-id: e3fc909d-2015-3000-1f64-d0e1cefbb2d4
< Strict-Transport-Security: max-age=31536000
< X-FRAME-OPTIONS: SAMEORIGIN
< SPRequestDuration: 15
< SPIisLatency: 1
* NTLM handshake rejected
* Authentication problem. Ignoring this.
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< MicrosoftSharePointTeamServices: 16.0.0.5423
< X-Content-Type-Options: nosniff
< X-MS-InvokeApp: 1; RequireReadOnly
< P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
< Date: Mon, 18 Jul 2016 10:50:57 GMT
< Content-Length: 0
* HTTP error before end of send, stop sending
<
* Closing connection 0
* SSLv3, TLS alert, Client hello (1):