Amin Hossein Nadi
Amin Hossein Nadi

Reputation: 11

Creating a Jira issue with a specific issue link using Jira Rest Java Client(JRJC)

I am using the Jira Rest Java Client (JRJC) to interact with Jira through its REST API. I am able to create a new issue successfully using the JRJC, but I am facing challenges in linking the newly created issue to an existing issue while creating it. I tried to follow the official Jira Rest API documentation for linking issues, but I am having difficulty implementing this functionality using the JRJC in Java. I want to achieve the following structure in the JSON request body for creating a new issue with a specific issue link (as shown below), but I am not sure how to do it programmatically using the JRJC:

{
   "fields":{
      "project":{
         "key":"TEST"
      },
      "summary":"test bug summary",
      "description":"test bug description",
      "issuetype":{
         "name":"Bug"
      },
      "priority":{
         "name":"Major"
      }
   },
   "update":{
      "issuelinks":[
         {
            "add":{
               "type":{
                  "name":"Blocks",
                  "inward":"is blocked by",
                  "outward":"blocks"
               },
               "outwardIssue":{
                  "key":"TEST-1"
               }
            }
         }
      ]
   }
}

I have tried various approaches, including using the FieldInput class to set the issuelinks field in the new issue, but I have not been successful in properly linking the issues. this is my java code for create issue:

IssueInputBuilder issueInputBuilder = new IssueInputBuilder(projectKey, issueTypeId, summary);
issueInputBuilder.setDueDate(DateTime.now());
// set another field using setFieldValue
IssueInput newIssue = issueInputBuilder.build();
restClient.getIssueClient().createIssue(newIssue).claim();

Could someone provide guidance or a code example on how to achieve this functionality correctly using the Jira Rest Java Client in Java?

Upvotes: 0

Views: 112

Answers (0)

Related Questions