Create Jira Issue using JiraRestClient (Java)

104 views Asked by At

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

0

There are 0 answers