我正在尝试使用IBM SBT创建一个活动,但这不起作用。
我的IBM SBT版本是1.1.11.20151208-1200(最新版本)。 IBM Connections Version是5.0 CR3。
我看过IBM的例子:
IBM Documentation - Creating activities
我有以下代码:
public static void testcreateData() throws ClientServicesException {
String serviceUrL = Variables.baseURL + "/activities/service/atom2/activities";
String content =
"<?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\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:thr=\"http://purl.org/syndication/thread/1.0\">"
+ "<title type=\"text\">New</title>"
+ "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" term=\"activity\" label=\"Activity\"/>"
+ "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/priority\" term=\"1\" label=\"Normal\"/>"
+ "<category term=\"tag1\" />" + "<category term=\"tag2\" />" + "<content type=\"html\">GoalOfActivity</content>"
+ "</entry>";
System.out.println( content );
Response res = Variables.anActivityService.createData( serviceUrL, null, content );
System.out.println( "Result: " + res.getResponse().getStatusLine().getStatusCode() );}
我的XML输出如下:
<?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" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:thr="http://purl.org/syndication/thread/1.0"><title type="text">New</title><category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="activity" label="Activity"/><category scheme="http://www.ibm.com/xmlns/prod/sn/priority" term="1" label="Normal"/><category term="tag1" /><category term="tag2" /><content type="html">GoalOfActivity</content></entry>
错误:
com.ibm.sbt.services.client.ClientServicesException: Request to url https://blabla.com/activities/service/atom2/activities returned an error response 415:Unsupported Media Type HTTP/1.1 415 Unsupported Media Type [Date: Wed, 13 Jan 2016 09:00:17 GMT, X-Frame-Options: SAMEORIGIN, Strict-Transport-Security: max-age=max-age=31536000;includeSubDomains, X-XSS-Protection: 1;mode=block, X-Permitted-Cross-Domain-Policies: master-only, X-Powered-By: Servlet/3.0, X-LConn-Auth: false, X-UA-Compatible: IE=9,8, Expires: Thu, 1 Jan 1970 00:00:00 GMT, Cache-Control: no-store, no-cache, must-revalidate, Accept: application/atom+xml, Set-Cookie: LtpaToken2=JYakBGXcJAWqNOfIc7PD5PKxpBf8spXAMh2RBtyQ/gCIFkLGuSFYLUq1Xkg335u3yLhI7lSuhNEQ4Y0j8DJB9DRr7jnQKNr8z6EwUs2Ak66eR4puAN5dvL+JiYsMj0Y9/QURoSALiLqkfWsByJpImJRRtEH8BHTaT811iaq/Cpux5h5XJ9uOPT420+4gqqzwuUyBc+71dLDs2XM/TwYx3ThTD+qA6nE42VFVszma7c4QmIrdvxASywOaFUQpCdLP63KTrs7NljOgqY82w0NNzcrz2VM3B4PUD5Fnht4HKkplB+7MBz4z1BDbwgc33BAdqNLKmd7b6vvFjAwDntIWAE7OL1rqP7k/w7rRgsqtUc1Ak074GhvkQvDjg89FeteKKG4Z7spfruNThmRWZ2IBiuQOj0cEb9LZwJMkcMrowpTWYxu0MTlcI+C9j3jV/xGK05hXvcYUmcm0HMpd0DJGE6e1J2uKEYaP7eoqjtScBtiVrGC1O1s8XXbw7vNcaUgsF0fc+3vCj0QZTJTxlNSixuRUxvRJHmTAkU7PpWMcmasTW2gQOOB6WtrST6j61865YUKSzMye8y73ps2n6+HAe87yVFNLBgm7omw+RMvCyKlhIE0go0bm2VrS2XUVMvPyT3vTo8Hlq5q1eYyzfwh2N56GhEc/H6c08Hh0K/9Mf+8=; Path=/; Domain=.blabla.com, Set-Cookie: JSESSIONID=0000MHOETW-Ow0ESyh_MllEfRId:1a17onpus; Path=/; HttpOnly, Vary: Accept-Encoding,User-Agent, Content-Length: 0, Keep-Alive: timeout=15, max=100, Connection: Keep-Alive, Content-Type: text/html, Content-Language: en-US]
我做了很多研究,但是当我使用互联网上的代码时,我总是得到了#400; 400 Bad Request&#34; - 所以我试着把重点放在IBM文档上,但那里的代码对我来说也不起作用。
有人知道怎么做吗?
祝你好运