Connecting jira through rest API

I am strugling with my code, where i need to connect to dev jira. I have a piece of code for it.

Also i coudn't find API for Jersey-client. So is there any way to connect jira using groovy scipt.

import com.atlassian.jira.rest.*;
import java.net.URI;
import java.net.URISyntaxException;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory;
import com.atlassian.jira.rest.client.*;




public static void connectToJiraREST() {

    final JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
    URI jiraServerUri;
    try {
        jiraServerUri = new URI("https://devjira.addteq.com/");
        //jiraServerUri = new URI("https://10.1.1.125:8080/");


        restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "admin", "welcome");

        issue = restClient.getIssueClient().getIssue(key, pm);

    } catch (URISyntaxException e) {
        e.printStackTrace();
    }catch (RestClientException e) {
        e.printStackTrace();
    }

}

1 answer

What problem are you having?

I can see two things right away.

1. You use an object called restClient on line 20. Where is that declared?

2. You use an object called pm on line 22. What is that? Where is it declared?

I think if you can answer those questions, you should be farther along towards getting your REST connection working.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

73 views 0 5
Read article

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