Jake
Jake

Reputation: 225

Join a Community using the IBM Connections API

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.

Upvotes: 1

Views: 252

Answers (1)

Paul Bastide
Paul Bastide

Reputation: 1503

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>[email protected]</email></contributor>
</entry>

Upvotes: 1

Related Questions