所以我在尝试以编程方式加入社区时遇到了一些问题(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>
&quot; generateRequestEntity&#39;函数只是用用户的电子邮件替换#EMAIL#。
然而,我收到500错误。任何帮助将不胜感激。
答案 0 :(得分: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>