Changes in Discourse 1.2.0.beta6 have affected group manipulation. The members.json output now includes members and meta keys, with a default limit of 50 members. To retrieve all members, add a limit parameter to the URL, e.g., http://discourse.example.com/groups/group_name/members.json?api_key=abc&api_username=admin&limit=9999.
Additionally, the API for adding users to groups has changed. Instead of making a PUT request to /admin/groups/group_id with group[usernames] parameters, use a PUT request to /admin/groups/group_id/members.json with usernames parameters for adding users, and a DELETE request with user_id parameter for removing users.
Group IDs are required for these API calls, and can be obtained by making a GET request to http://ask.twobydev.com/groups/group_name.json. There is currently no way to add members to a group using the group name instead of the group ID, as noted by OnceWas and confirmed by AdamCapriola.
I have a SSO setup with group syncing, and I noticed the output from members.json has changed from being simply an array with members to having these keys:
members (contains array of members that was the only output before)
meta (contains array with keys total, limit, and offset)
The limit value comes up as 50 by default, so only 50 of the group members are displayed in the members array, which may be troublesome if you are doing group syncing and need to retrieve all the members in the group.
The solution is to add a limit parameter onto the .json that’s consumed, like this:
It has always been possible for groups to have >200 members in the database, but the UI and API have hard-limited the number of results returned to membership requests. As you noticed the API supports it now, but the UI still needs work.
Also, I noticed that the API for adding users to groups is different now. Previously, I’d make a PUT request here:
/admin/groups/group_id
And pass group[name], group[alias_level], group[visible], and group[usernames] parameters where usernames was all the members of the group, comma separated. Now the location is:
/admin/groups/group_id/members.json
And you PUT usernames (which is now only usernames to be added to the group, comma separated). To remove a user from the group, a DELETE request is needed with parameter user_id.
Not that I know of. I’ve just been picking out IDs and using them in my code. /groups/group_name.json is helpful for determining them, like you’ve figured out.