connection error while using rest api

    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

This widget could not be displayed.

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

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

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

169 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you