User provisioning API removing user from group


I’m trying to remove a user from a group and having this Instruction set for users — Nextcloud latest Administration Manual latest documentation as a reference.

But I get a statusCode of “996” with the message “Internal Server Error”. I dig deeper and found the problem is the second parameter (groupid) for the method UsersController::removeFromGroups is expected to be a string, but null is received. Actually there is no parameter groupid in the parameter bag of the request object.

This is the code I running:

$url = $cloudUrl.$url_OCS_Users.‘/users/my_user/groups’;
$groupName = ‘GROUP_TEST’;

$handle = curl_init($url);
curl_setopt($handle, CURLOPT_HTTPHEADER, array(
'Authorization: Basic '. $auth,
‘OCS-APIRequest: true’,
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, ‘DELETE’);
$data = [
‘groupid’ => $groupName,
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($handle);

Instead of calling with DELETE method I call with POST method and everything is ok (the user is added to a group in this case).

How can I send the groupid parameter in case of DELETE?

Thanks in advance

Solved (for me).
I couldn’t pass the groupid in the payload, so I change route definition in apps/provisioning_api/appinfo/routes.php to
[‘root’ => ‘/cloud’, ‘name’ => ‘Users#removeFromGroup’, ‘url’ => ‘/users/{userId}/groups/{groupid}’, ‘verb’ => ‘DELETE’],

Now I can remove users from groups.

Anyway, is someone knows the solution without changing nextCloud source code, it will be very helpfull.