【问题标题】:Join a Community using the IBM Connections API使用 IBM Connections API 加入社区
【发布时间】:2015-04-07 18:47:02
【问题描述】:

所以我在尝试以编程方式加入社区时遇到了一些问题 (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)

这是我的请求代码:

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;
    }

这是我的 XML 文件:

<?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>

“generateRequestEntity”函数只是将#EMAIL# 替换为用户电子邮件。

但是,我收到了 500 错误。任何帮助将不胜感激。

【问题讨论】:

    标签: xml rest ibm-connections


    【解决方案1】:

    你应该从

    改变你的入口节点
    <entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">
    

    <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">
    

    我用过

    <?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>
    

    【讨论】:

    • 说得太早了。如果您还不是社区的一员,它会出现 400 秒。不过好消息是,如果您遇到了 409 错误,这对应于您已经在社区中。
    • 想通了。如果您向 /atom/community/members 而不是 /atom/community/requestsToJoin 发出请求,您将获得 201 以成功添加。
    猜你喜欢
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多