Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create/Update group with custom_fields #263

Closed
hartois opened this issue Apr 5, 2021 · 5 comments · Fixed by #359
Closed

Create/Update group with custom_fields #263

hartois opened this issue Apr 5, 2021 · 5 comments · Fixed by #359
Assignees
Milestone

Comments

@hartois
Copy link

hartois commented Apr 5, 2021

Hello, please add feature for setting custom_fields in Group on create/update such as in User

@Art4 Art4 added the question label Apr 5, 2021
@Art4
Copy link
Collaborator

Art4 commented Apr 5, 2021

Hey, this feature has no details in Redmine documentation: http://www.redmine.org/projects/redmine/wiki/Rest_Groups#PUT

If someone can figure out how the API works we would be happy about more information or a PR.

@Art4 Art4 added enhancement pending: help wanted help and PRs are welcome and removed question labels Apr 5, 2021
@hartois
Copy link
Author

hartois commented Apr 6, 2021

It's work same as in User:
curl -H "Content-Type: application/json" -X POST -H 'X-Redmine-API-Key: <API_KEY>' --data-raw '{"group":{"name":"test3","custom_fields":[{"id":2,"value":"testvalue"}]}}' http://redmine.local/groups.json

will create group with custom field of id 2, value - "testvalue"

@kbsali
Copy link
Owner

kbsali commented Apr 6, 2021

@hartois if it is similar to the User API, how about proposing a pull request with the changes you are after? :)
Thanks!

@Art4
Copy link
Collaborator

Art4 commented Apr 6, 2021

@hartois You can start with extending the Group class and implement the missing feature. If you are sure that it works you can post it here or create a pull request and we will be happy to merge it.

class GroupApi extends \Redmine\Api\Group
{
    public function update($id, array $params = [])
    {
        // Build your implmeentation here
        return $this->put('/groups/'.$id.'.xml', $body);
    }
}

// try using it
$groupApi = new GroupApi($redmineClient);
$return = $groupApi->update(12, []);

@Art4 Art4 added this to the v2.5.0 milestone Jan 10, 2024
@Art4 Art4 removed the pending: help wanted help and PRs are welcome label Jan 10, 2024
@Art4 Art4 self-assigned this Jan 10, 2024
@Art4
Copy link
Collaborator

Art4 commented Jan 10, 2024

Creating a group with custom_fields is already possible:

$client->getApi('group')->create([
    'name' => 'asdf',
    'user_ids' => [1, 2],
    'custom_fields' => [
        [
            'id' => 123,
            'name' => 'cf_name',
            'value' => 'cf_value',
        ],
    ],
]);

I will update the docs and working at the feature to updating groups and custom_fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants