Dear Nextcloud Community,
I hope you are all doing well. I am new here and hope you can help me with a small problem. Using the WebDAV API, I have already automated some tasks, such as creating users and folders, including assigning folder permissions and tags.
Now, I am facing the challenge of allowing a user who is not part of the admin group to assign tags that are marked as “not visible.” Unfortunately, I have not been able to figure out how to achieve this. However, I do know that this is not currently possible via the Web GUI but should be achievable via the WebDAV API.
I also found this article, but unfortunately, I do not have full access to it since I am not part of the respective community:
https://portal.nextcloud.com/article/Collaboration/Managing-tags-by-group
My question to you is whether anyone has done something like this before and could help me grant such a “permission” via the WebDAV API. Perhaps I am using the wrong or a non-existent endpoint. Since I could not find much documentation, I am pretty much in the dark and just guessed.
Here is a simple script (with PROPPATCH and curl) I came up with, which might work in principle if I use the correct parameters:
<?php
$nextcloudUrl = 'https://your-nextcloud-url.com';
$username = 'admin-username';
$password = 'admin-password';
$userId = 'username';
$tagId = 1; // Example ID
$endpoint = $nextcloudUrl . '/remote.php/dav/systemtags/' . $tagId . '/assign';
$xmlBody = '<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:set>
<d:prop>
<oc:assign>
<oc:user>' . $userId . '</oc:user>
</oc:assign>
</d:prop>
</d:set>
</d:propertyupdate>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PROPPATCH");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/xml"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlBody);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 207) {
echo "Permission successfully granted.";
} else {
echo "Error: HTTP Code $httpCode, Response: $response";
}
?>
Does anyone have an idea how to make this work? I appreciate any tips.
Best regards, tom