Forums

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

I am trying to create an issue using JRJC but unable to create issue as exception is thrown, help me

Santosh Penjarla January 2, 2019

I am able to retrieve the issues already available using the issueKey but I want to create the issue,here is the function I used :

public String createIssue(String projectKey, String issueSummary) {
IssueRestClient issueClient = this.jiraRestClient.getIssueClient();
IssueInput newIssue = new IssueInputBuilder(projectKey,1L,issueSummary).build();
Promise<BasicIssue> pIssue = null;
try{
pIssue= issueClient.createIssue(newIssue);
}
catch(Exception e){}
return pIssue.claim().getKey();
}

output :
com.atlassian.jira.rest.client.RestClientException: valid issue type is required
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:165)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:159)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:48)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:12)
at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:285)
at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:162)
at com.google.common.util.concurrent.Futures$6.run(Futures.java:799)

 

2 answers

2 accepted

0 votes
Answer accepted
Santosh Penjarla January 2, 2019
ArrayList<IssueType> issueTypes = Lists.newArrayList(jiraClient.jiraRestClient.getMetadataClient().getIssueTypes().claim());

for ( IssueType issue : issueTypes){
System.out.println("Issue Name : " + issue.getName() + " , Issue ID : " + issue.getId());
}
0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
January 2, 2019

The error message is pretty clear - you've not given it a valid issue type to create.

Santosh Penjarla January 2, 2019

Yes, I tried to get the valid values of the issue types but unable to find them 

can you suggest me some way to get valid values for all the issue types ?

Nic Brough -Adaptavist-
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.
January 2, 2019

Use the "create meta" call to get a list of values - see https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-discovering-meta-data-for-creating-issues-6291669/  (I don't use the JRJC, so I don't know if it supports it.  I found it just gets in the way of me using the API properly)

Santosh Penjarla January 2, 2019

page not found 404

Nic Brough -Adaptavist-
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.
January 2, 2019

This forum software often adds crud to the end of urls - remove everything from the first % onwards and try again.

Like Santosh Penjarla likes this
Santosh Penjarla January 2, 2019

ArrayList<IssueType> issueTypes = Lists.newArrayList(jiraClient.jiraRestClient.getMetadataClient().getIssueTypes().claim());

for ( IssueType issue : issueTypes){
System.out.println("Issue Name : " + issue.getName() + " , Issue ID : " + issue.getId());
}

 above provided code can be used to retrieve all the issues created in your
jira projects of your jira account

Suggest an answer

Log in or Sign up to answer