This article will focus on how to make connection to upload and download files to sharepoint site through linux shell script.
I tried using curl as below but I did not get output neither the file uploaded.
curl --ntlm --user username:password --upload-file myfile.xls https–://sharepointserver.com/sites/mysite/myfile.xls
Has anybody actually manage to get this working with SharepointOnline(hereafter abbreviated to SPO)? I created an app on SPO, with appropriate permissions. I then created a script to retrieve the token from SPO, which works fine, but when trying to use the token to upload to SPO, I keep getting a 401 error, thinking I might have a error in my CURL command.
curl -i -H “Authorization: Bearer $(./get_access_token.sh)” -H “Accept: application/json;odata=verbose” --upload-file testfile destination(sorry seems new users cannot post urls)
Hi sandmann, the problem is the token changes every time you query it, so by the time I have copied it and inserted into the upload, the token is no longer valid, so need to do it on the fly
This makes sense, because curl by default does not keeps the session, so from the server side the requests are distinct sessions, thus get distinct tokens. I would suggest digging a bit around curl’s session keeping, cookie handling and such. While that should work on most websites, I’m not sure about Sharepoint.