Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error uploadig a file to NextCloud via API

I'm trying to upload a file:

curl -X PUT -u "my_username:pass123" "https://nextcloud.my_domain.com/remote.php/webdav/Shared/dir1/" --data-binary @"/Users/user1/test1.png"

Error:

  <?xml version="1.0" encoding="utf-8"?>
  <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <s:exception>Sabre\DAV\Exception\Conflict</s:exception>
    <s:message>PUT is not allowed on non-files.</s:message>
  </d:error>

Why?

The credentials I'm using are the ones I use for login in the browser.

like image 681
Nattemando Avatar asked Jan 18 '26 03:01

Nattemando


1 Answers

The PUT request needs to refer to the actual file you want to create, right now you are pointing to a directory.

So instead of:

https://nextcloud.my_domain.com/remote.php/webdav/Shared/dir1/

Use:

https://nextcloud.my_domain.com/remote.php/webdav/Shared/dir1/test1.png
like image 71
Evert Avatar answered Jan 21 '26 01:01

Evert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!