Search code examples
ldapibm-sbtibm-connections

Adding groups as members to a Connections community through the API


I am looking for a way to add a group as a member to community when I know the groupName (from the Directory Server).

When I add a group to a community through the UI I can pick from existings groups, but I have not found the API equivalent of this call yet.

Is does not seem to be a profile, entering the snx:userid

<snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">AB16E3DF-D544-4984-94AE-FAAC7A5F2AA6</snx:userid>

To the profileservice endpoint:

https://CONNECTIONSHOST/profiles/atom/profile.do?userid=AB16E3DF-D544-4984-94AE-FAAC7A5F2AA6

Does not return a profile...

So the question is , how can I add a (LDAP) group as a member to a community when I don't have the sn:userid but only the groupname ?


Solution

  • Try the following METHOD = POST AUTHORIZATION = {BASIC}|{OAUTH} CONTENT-TYPE application/atom+xml URL PATTERN = communities/service/atom/community/members?communityUuid=${communityUuid} METHOD POST

    Where the communityUuid is the community's unique id

    The payload should be

    <?xml version="1.0" encoding="UTF-8"?>
    <entry 
     xmlns="http://www.w3.org/2005/Atom" 
     xmlns:app="http://www.w3.org/2007/app" 
     xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
    <contributor>
    <snx:userid>ID OF GROUP</snx:userid>
    <snx:role>member</snx:role>
    </contributor>
    <category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="group"></category>
    <snx:role component="http://www.ibm.com/xmlns/prod/sn/activities">member</snx:role>
    </entry>
    

    Then replace the ID of Group with your group's ID, and then you will be able to add the group to the community.