connection error while using rest api

Fadi Hussien June 7, 2015

    Hi

 

I'm trying to recive issues from JIRA by rest api and i got connection error when running the below code.

can anyone help ???

notice that i dont use internal server

are there any configuraion should i do?

please see exception below

 

thanks

    

 

 

    public class JiraConnection {

 

      

       public static void main(String[] args) throws Exception {

             

        JerseyJiraRestClientFactory f = new JerseyJiraRestClientFactory();

       JiraRestClient jc = f.createWithBasicHttpAuthentication(new URI("https://xxxxxxx.atlassian.net"), "fadih@xxxxxx.com", "1234567");

 

        SearchResult r = jc.getSearchClient().searchJql("type = Epic ORDER BY RANK ASC", null);

        

        Iterator<BasicIssue> it = r.getIssues().iterator();

        while (it.hasNext()) {

            

            Issue issue = jc.getIssueClient().getIssue(((BasicIssue)it.next()).getKey(), null);

            

            System.out.println("Epic: " + issue.getKey() + " " + issue.getSummary());

            

            Iterator<IssueLink> itLink = issue.getIssueLinks().iterator();

            while (itLink.hasNext()) {

                

                IssueLink issueLink = (IssueLink)itLink.next();

                Issue issueL = jc.getIssueClient().getIssue((issueLink).getTargetIssueKey(), null);

                

                System.out.println(issueLink.getIssueLinkType().getDescription() + ": " + issueL.getKey() + " " + issueL.getSummary() + " " + issueL.getField("Story Points"));

                

            }

            

        }

        

    }

        

           private static Transition getTransitionByName(Iterable<Transition> transitions, String transitionName) {

               for (Transition transition : transitions) {

                   if (transition.getName().equals(transitionName)) {

                       return transition;

                   }

               }

               return null;

           }

 

}

 

 

 

Exception :-

 

Exception in thread "main" java.lang.NoSuchMethodError: com.sun.jersey.client.apache.ApacheHttpClientHandler.<init>(Lorg/apache/commons/httpclient/HttpClient;Lcom/sun/jersey/api/client/config/ClientConfig;)V

       at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClient.createDefaultClientHander(JerseyJiraRestClient.java:134)

       at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClient.<init>(JerseyJiraRestClient.java:59)

       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 JiraConnection.main(JiraConnection.java:27)

 

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 7, 2015

Your code is passing the wrong type of data into the connection handler, or you aren't importing the correct libraries for that call.

Fadi Hussien June 8, 2015

whats mean ??? can you please give example that work ???? also which user permission need for connection thanks

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 8, 2015

It means your code is doing something the library is not built for, it's making a call that can't be handled. I can't really tell you more than that, the error message is referring to code you have not posted. I can't give you an example that works, because I have no idea what you're doing here, and it's not the code that's failing anyway. Users trying to use REST have the same rights that they would get if they logged into the UI

Suggest an answer

Log in or Sign up to answer