Upload file with curl

Hello

I am trying to upload a pdf file with curl command:

curl -u myUser:myPassword -H ‘Content-Type: application/pdf’ -T ‘report_96.pdf’ ‘https://cloud.oseom-finance.fr/remote.php/dav/files/myUser/OSEOM_FINANCE/IBRM/Reddition_comptes/Rapports/

but it gives an error:

<?xml version="1.0" encoding="utf-8"?>

<d:error xmlns:d=“DAV:” xmlns:s=“sabre/dav”>
<s:exception>Internal Server Error</s:exception>
<s:message>
The server was unable to complete your request. If this happens again, please send the technical details below to the server administrator. More details can be found in the server log. </s:message>

<s:technical-details>
	<s:remote-address>81.13.198.36</s:remote-address>
	<s:request-id>KjRYsUADGVQpf1t5x6I6</s:request-id>

	</s:technical-details>

</d:error>

Uploading from a browser works fine.

Downloading files also works, for example:

curl -u myUser:myPassword -O ‘https://cloud.oseom-finance.fr/remote.php/dav/files/myUser/OSEOM_FINANCE/IBRM/Reddition_comptes/Rapports/Acte Cession.pdf’

What can be wrong with my curl upload? I tried PUT, POST and -H ‘X-Requested-With: XMLHttpRequest’ but get the same error.

Barbara

I found out how to do it.
I had to create an application password in settings, security and use this password in my curl command.

4 Likes

Are you sure that’s what it was? Uploading does not require an app password (well maybe with 2FA).

And your first command looks fine (also I tested it to be sure).

The main two things I can think of:

  • Since you’re not specifying the filename in the destination, if the trailing slash is left off with the -T option to curl than it’ll likely fail. In you example you have it, but maybe that got dropped during some testing?
  • The destination folder must exist beforehand (or you just issue a curl MKCOL to create it beforehand). Of course once the folder exists, that curl command would suddenly start working.

In general, when you see an Internal server error (particularly one with a request-id embedded in it like that), you can try looking for an associated log entry in your Nextcloud log.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.