Search code examples
owncloudnextcloud

NextCloud file tagging through WebDAV script


I am using NextCloud 11 to store my personal files, and I use the simple curl script from the documentation in order to upload files to my NextCloud drive:

curl -u user:pw -T test.pdf "http://localhost/nextcloud/remote.php/dav/files/user/test/test.pdf"

Moreover, I would like to directly add some tags to the uploaded files. However, in the official documentation, they just show how files can be uploaded, deleted and moved through the WebDAV interface.

Does anybody have a hint how I could tag a file remotely?

I have posted the same question in the official NextCloud community forum, but I did not receive a response yet. In case I receive a response, I will post it here.


Solution

  • POST https://yournextcloud.com/index.php/api/v1/files/path/to/file

    Payload is JSON:

    {"tags": ["tag1", "tag2"]}
    

    You will need to authenticate yourself using Basic Auth

    Edit: The API can only be called from inside Nextcloud because the CSRF token is required.