Search code examples
redmineredmine-api

Redmine API Users in Groups


I am Making a wpf app that shows some data from redmine using Redmine.Net.Api. I just want to display users that belong to redmine Groups. I can get all groups

Redminemanager manager = new RedmineManager(Config.host, Config.apiKey);
var groups = manager.GetObjects<Group>();

I get groups names right, but the users are always Null.

I tried too the Groups under User class:

 Redminemanager manager = new RedmineManager(Config.host, Config.apiKey);
  var redmineUsers = manager.GetObjects<User>() 

Groups there are always null too.

I don't get this, I hope someone can help. Thanks in advance.


Solution

  • It's about how the Redmine REST API works: by default, listing a group WONT retrieve the users.

    The Redmine REST API documentation, GET Groups section, says:

    GET

    Returns details of a group.

    This endpoint requires admin privileges.

    Parameters:

    • include (optional): a coma separated list of associations to include in the response:
      • users
      • memberships

    I tried a GET /groups/1.json on my local Redmine installation without the include=users and actually doesn't retrieve the users. When I add the ?include=users it works like a charm

    On the official Redmine.Net.API Wiki on Github there is an example using these include parameters.

    It's something like this:

    var group = manager.GetObject<Group>(groupId, 
                                    new NameValueCollection() { { RedmineKeys.INCLUDE, RedmineKeys.USERS } });
    

    Good luck.