File upload to Sharepoint using curl failing

Leon Pappadopoulos 20 Reputation points
2023-10-09T15:56:03.3266667+00:00

Good day

I hope you are well

I need to transfer a file from a unix system to Sharepoint but I'm having a variety off issues. I have tried to follow the recommendations I have found on Microsoft as well as Google to no avail. The typical error seems to be HTTPS 403 (Forbidden) . I am using user /password authentication. The browser interface works to Sharepoint so I know the credentials are working

The URL I'm using is

curl -v -u user:password -d @myPDF.pdf https://my.sharepoint.com/site/path/AllItems.aspx/myPDF.pdf -H "Content-type:application/pdf"

By the way: If I don't use the @file curl complains that the file does not exist

I have tested this on Linux and Solaris SPARC and do not get any joy. Alas Sharepoint does not support SFTP.

Any Assistance in this regard will be gratefully accepted.

Many Thanks

Kind regards

Leon

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-10-10T05:42:28.04+00:00

    Hi @Leon Pappadopoulos

    As far as I know

    403 error usually caused by your permissions to the folder haven’t replicated correctly on the server.

    Maybe you can try this

    curl --ntlm --user user:password --upload-file myPDF.pdf https://my.sharepoint.com/site/path/myPDF.pdf -H "Content-type:application/pdf"
    
    
    

    However, during my investigation, I found that it may not necessarily be supported:

    https://sharepoint.stackexchange.com/questions/205271/use-curl-to-upload-files-to-sharepoint-online

    I think Power shell might be a better choice:

    Here is a link for your referece:

    https://theitbros.com/powershell-upload-file-to-sharepoint/


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Leon Pappadopoulos 20 Reputation points
    2023-10-13T14:12:03.7+00:00

    Hi Cheng Feng

    Apologies for the late reply.

    Thank you so much for all your efforts. Not sure what the issue was with curl but I abandoned curl and went the Powershell route that you suggested.

    I managed to get that working and all is right with the world.

    Many thanks

    Leon

    0 comments No comments

  2. Leon Pappadopoulos 20 Reputation points
    2023-10-13T14:13:41.0533333+00:00

    The powershel solution suggested by Cheng Feng worked for me

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.