Changes to group manipulation in 1.2.0.beta6

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:

http://discourse.example.com/groups/group_name/members.json?api_key=abc&api_username=admin&limit=9999

And you will need to update your code to account for the output having the two keys now.

Also: Are groups able to have more than 201 members now?? It seems so… :drevil:

2 Likes

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.

2 Likes

Sweet! The UI looks pretty good to me.

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.

4 Likes

@AdamCapriola how do you get the group ID? XHR inspector shows the ID, but is there a way to get the ID of the group other than a GET to http://ask.twobydev.com/groups/group_name.json?

Or, maybe the underlying question is: Is there any way to add members to a group using the group name instead of the group 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.