Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect to a jira server through API?

Laszlo Szilagyi November 10, 2011

Hi,

I'm about to create a small stand alone java application to execute basic queries against our Jira server. I did not find any examples how to do that.
What I'm expecting is a kind of connection object, where I can set up all the necessary settings like host, port, username, password.

So basically I just want to connect get an issue by id, check its fields, or something like that. Play around with that.
This would be extremly helpful before I do my plugin development, because I could test my code very quickly, get used to the api, debug the code locally, etc.

Is this doable?

Apprectiate any help,
LACi

2 answers

1 accepted

0 votes
Answer accepted
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2011

You can use the REST Api and use requests like http://example.com:8080/jira/rest/api/2.0.alpha1/issue/{issueKey} to get information about issues. I like this since you can prototype your requests rapidly in the browser.

Or you use the SOAP API which takes a little more effort since you first have to create your WSDL. Here is a nice Blog how to use it: http://www.j-tricks.com/1/post/2010/8/jira-soap-client.html

Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2011

Ok, i understand your question better now. To speed up the development process, please check this

That way you avoid the annoying Tomcat restart. Works nicely!

Laszlo Szilagyi November 10, 2011

Thanks a lot! That atlas-cli looks promising. Also the REST API can come in handy if I want to quickly check something.

So it seems what I originally wanted is not doable, namely to connect to the JIRA server from my own standalone app.
Not a big deal, I'm totally fine with these workarounds, just good to know.

Thanks,
LACi

1 vote
Mikael Löwenadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2011
Laszlo Szilagyi November 10, 2011

Thanks for the quick response, but I think this is not what I'm looking for.

I want to create a java class file with my own main method, where I could use the API to connect to Jira and do some operations. I want to query an issue, check it's fields, maybe acces some custom fields, things like that.

I'm in a development of a custom field type plugin, but at first I want to see how my code works in a basic test app. I don't want to re-run always the atlas-run to see the effect of my code change. It's just too time consuming. Also from a standalon app I could easily debug my code.

For example I want to see the result of a code like this:

// get the Priority
PriorityImpl priority =  (PriorityImpl)issue.getPriorityObject();
String priority = priority.getName();
		
// get the Severity
CustomField severity = ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObject("customfield_10182");



That's the rational behind this question.

Thank you

Laszlo Szilagyi November 21, 2011

It seems I would need to connect to a JIRA server again from a standalone application through the API.
Is this possible? Could someone please confirm this?

I want to play around with the JQL API to see how it works. I don't want to install any plugin to at this point I just want to test the API functions with real data.

What should I do?

Example code:

ParseResult pr = searchService.parseQuery(userUtil.getUserObject(adminUserName), "\"Project Team\" = \"wpo\" and issuetype = Bug");
Query query = pr.getQuery();
SearchResults searchResults;
Collection issues = new ArrayList();
try
{
	searchResults = searchService.search(userUtil.getUserObject(adminUserName), query, PagerFilter.getUnlimitedFilter());
	issues = searchResults.getIssues();
}
catch (SearchException e)
{
	// TODO Auto-generated catch block
	e.printStackTrace();
}




Thanks,
LACi

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events