Is there any rest api call to link user to groups and categories?

(Boopathi S) #1

i wish to make link or add a user to particular group and category via rest api call ? whether is it possible.suggest some ideas.

(Roarke Lynch) #2

You can add a user to a group through a POST to /admin/users/USER_ID/groups. Include the group_id as a param.

You can remove a user from a group through a DELETE to /admin/users/USER_ID/groups/GROUP_ID.

(Boopathi S) #3

thanks bro…how to get the specific group details … get method admin/groups/group_id or something else it possible to add users in to group with email as param… get the specific user details through user_id…

(Tom Newsom) #4

I’ve been working on exactly this problem and found that this worked:

  1. Get list of groups and their IDs with /admin/groups.json
  2. Get a user’s username with
    -d /admin/users/list/active.json
  3. Now you have the group ID and the username, you can add the user to the group with
    PUT -d usernames=username /admin/groups/GroupIdGoesHere/members.json
  4. And remove the user from the group with
    DELETE -d username=username /admin/groups/GroupIdGoesHere/members.json

Note that the PUT command will accept a comma separated list of usernames, but the the DELETE command will only do one member at a time.

(Boopathi S) #5

thanks tom: but i asked to get the specific group details through group_id like this:
admin/groups/group_id is it correct one? else any changes needed?