我可以使用剩餘的客戶端API創建jira問題,但我無法將screeshot /附件附加到存在的JIRA
問題。如果有人能提供一個真正感激的解決方案,那將會非常有幫助。如何使用rest-client API添加附件到現有的JIRA問題
我剛剛寫了下面的代碼片段,用於將jpeg文件附加到現有的JIRA Issue
。但後來我經歷「異常線程 「main」 java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager"
代碼段: -
私人靜態字符串addAttachment(字符串attachmentfilepath)拋出的URISyntaxException,FileNotFoundException異常{
final java.net.URI jiraServerUri = new java.net.URI("https://oliveits.atlassian.net");
FileInputStream fileStreamPath = new FileInputStream(attachmentfilenamepath);
JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
NullProgressMonitor pm = new NullProgressMonitor();
System.out.println("Server Url :"+jiraServerUri);
JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri,"mobileqa","MobileQA1234");
Issue issue1 = restClient.getIssueClient().getIssue(newKey, pm);
final java.net.URI AttachmentUri = new java.net.URI(jiraServerUri+"/rest/api/2/issue/"+newKey+"/attachments");
System.out.println("URI :"+issue1.getAttachmentsUri());
//restClient.getIssueClient().addAttachment(pm,issue1.getAttachmentsUri(), fileStreamPath , imageName);
restClient.getIssueClient().addAttachment(pm, AttachmentUri, fileStreamPath, imageName);
return attachmentfilepath;
}
例外: -
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.create(JerseyJiraRestClientFactory.java:34)
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.createWithBasicHttpAuthentication(JerseyJiraRestClientFactory.java:39)
at com.jtricks.JTricksRESTClient.addAttachment(JTricksRESTClient.java:157)
at com.jtricks.JTricksRESTClient.main(JTricksRESTClient.java:101)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpConnectionManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
只是將缺少的jar文件添加到類路徑中,但我收到如下所述的異常:
異常Msg-1:com.sun.jersey.api.client.ClientHandlerException:Java類com.sun.jersey.multipart.MultiPart和Java類型com.sun.jersey.multipart的消息主體編寫器。 MultiPart和MIME媒體類型multipart/form-data; boundary = Boundary_1_18541827_1358346116249未找到
異常Msg-2:com.sun.jersey.api.client.ClientHandlerException:Java類com.sun.jersey.multipart.MultiPart和Java類com類的消息正文編寫器。 sun.jersey.multipart.MultiPart和MIME媒體類型multipart/form-data; boundary = Boundary_1_18541827_1358346116249未找到
非常感謝您的回覆,我只是將commons-httpclient jar文件添加到classpath中。但它不起作用,但後來我得到了一個不同的異常 –
線程「主」java.lang.NoClassDefFoundError異常:com/sun/jersey/client/apache/config/ApacheHttpClientConfig –
現在你缺少jersey-apache-客戶端:http://mvnrepository.com/artifact/com.sun.jersey.contribs/jersey-apache-client/1.1.3-ea – Archer