0

I am trying to programmatically create issues in Jira using the JiraRestClient. I am using the following dependencies

compile 'com.atlassian.jira:jira-rest-java-client-api:5.2.4' compile 'com.atlassian.jira:jira-rest-java-client-core:5.2.4'

And have the following code to create java issues.

    @SneakyThrows
    public BasicIssue createIssue(JiraIssueType jiraIssueType) {
        return jiraRestClient.getIssueClient().createIssue(
                IssueInput.createWithFields(
                        new FieldInput(IssueFieldId.PROJECT_FIELD, PROJECT_KEY),
                        new FieldInput(IssueFieldId.ISSUE_TYPE_FIELD, jiraIssueType.getValue()),
                        new FieldInput(IssueFieldId.SUMMARY_FIELD,
                                String.format("Add new dataset %s to object type %s", "toy",
                                        "story")),
new FieldInput(IssueFieldId.DESCRIPTION_FIELD, "descrption")
                )).fail(throwable -> log.error(throwable.getMessage()))
                .claim();
    }

However when I run the following code I see the following error in the stack trace

Caused by: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={issuetype=Can not instantiate value of type [simple type, class com.atlassian.jira.rest.api.issue.ResourceRef] from JSON integral number; no single-int-arg constructor/factory method, project=project is required}, errorMessages=[]}]}
    at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:176)
    at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:170)
Caused by: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={issuetype=Can not instantiate value of type [simple type, class com.atlassian.jira.rest.api.issue.ResourceRef] from JSON integral number; no single-int-arg constructor/factory method, project=project is required}, errorMessages=[]}]}

I have tried downgrading the java client to a lowerversion but that did not seem to work

1 Answer 1

-1

You can try using IssueInputBuilder to create the issue and set the description. This approach can help avoid errors related to instantiating ResourceRef type from JSON integral number. Here's an example of how you can create the issue using IssueInputBuilder:

IssueInputBuilder issueInputBuilder = new IssueInputBuilder(projectKey, issueTypeId, summary);
issueInputBuilder.setDescription("descrption");
IssueInput newIssue = issueInputBuilder.build();
jiraRestClient.getIssueClient().createIssue(newIssue).claim();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.