Group Membership via REST Api

Dear all,

I am trying to automate management of some TAO resource creation using the REST API (via taoTestTaker/api and taoGroups/api endpoints).

I manage to create/update/... test-takers and groups. Now I would like to add test-takers to groups. I have seen there is a member parameter that is allowed to be passed to PUT method on taoGroups/api endpoint unfortunately I did not succeed to use it.

Digging around in the code, I do not understand how it could work. The (PUT) REST call of taoGroups/api is expecting a uri parameter (uri of the group), and the uri of a test-taker via the member parameter. This parameter is not managed specifically, therefore it is managed by the update method of the 'tao/models/classes/class.CrudService.php' and then the editPropertyValues method of generis/core/kernel/classes/class.Resource.php which eventually adds the property to the group resource. Unfortunately, if I am right the property (\TAOGroup.rdf#member) should be added to the test-taker/user resource and not the group.

I successfully added a test-taker to a group by overriding the update method in taoGroups/models/CrudGroupsService.php as follows :

    public function update($uri = null, $propertiesValues = array())
        if (isset($propertiesValues[GroupsService::PROPERTY_MEMBERS_URI])) {
            $this->getClassService()->addUser($propertiesValues[GroupsService::PROPERTY_MEMBERS_URI], new core_kernel_classes_Resource($uri));
        parent::update($uri, $propertiesValues);

At the moment, I only adds user to the group (I should also manage the removal of users and therefore provide the whole list of user uri as parameter) but before to continue with this solution, I would like to know if this is a bug or if I miss the correct way to add a member to a group.

Thanks for you help,

Sign In or Register to comment.

We use cookies on our website to support technical features that enhance your user experience. Cookie Policy Privacy Policy