1

So I'm having some issues trying to programatically join a community (http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_a_request_to_join_a_community_ic50&content=apicontent)

Here is my request code:

private boolean verifyCommunityMembership(String username, String password) throws HttpException, IOException {
    HttpClient client = new HttpClient();
    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
    AuthScope authscope = new AuthScope("w3-connections.ibm.com", AuthScope.ANY_PORT, AuthScope.ANY_REALM);
    client.getState().setCredentials(authscope, credentials);
    PostMethod postMethod = new PostMethod("https://w3-connections.ibm.com/communities/service/atom/community/requestsToJoin?communityUuid=758e69a5-47e6-4843-abb7-db1b9ef194f9");

    RequestEntity requestEntity = generateReplyEntity("CommunityJoinTemplate.xml", null, null, null, username);
    postMethod.setRequestEntity(requestEntity);
    int statusCode = client.executeMethod(postMethod);
    if(statusCode == 200 || statusCode == 409){
        return true;
    } else {
        return false;
    }

and here is my XML file:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">
    <contributor> <email>#EMAIL#</email></contributor>
</entry>

The 'generateRequestEntity' function simply replaces #EMAIL# with the users email.

However, I'm getting a 500 error back. Any help would be much appreciated.

Jake
  • 225
  • 1
  • 2
  • 12

1 Answers1

1

you should change your entry node from

<entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">

to

<entry xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">

I used

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">ignored</title>
<content type="html">reason to join</content>
<contributor> <email>ajones4@janet.iris.com</email></contributor>
</entry>
Paul Bastide
  • 1,505
  • 4
  • 17
  • 22
  • Spoke too soon. It appears it 400s out if you're not already part of the community. Good news though, if you are you get the 409 error, which corresponds to you being already in the community. – Jake Apr 10 '15 at 22:45
  • Figured it out. if you make a request to /atom/community/members instead of /atom/community/requestsToJoin, you'll get a 201 back for successful add. – Jake Apr 10 '15 at 23:02