Linking a New Jira Ticket to an Existing One with the Jira REST Java Client

How can I connect a newly created Jira ticket to a pre-existing one using the Jira REST Java client? I need a working example, for instance:

IssueDetailsBuilder builder = new IssueDetailsBuilder("PROJ", "ISS-100", "Defect Report");
builder.setDeadline(java.time.LocalDate.now().toString());
builder.addIssueLink("Relates", "PROJ-50");
IssueDetails ticket = builder.build();
jiraConnector.getIssueService().submit(ticket).claim();

In my experience, linking issues with the Jira REST Java client requires a careful check on the issue link type and ensuring the proper permissions are in place. I once encountered an issue where the link wasn’t being processed because the link type was mistyped. Verifying that the format is exactly what your Jira instance expects saved me a lot of debugging time. Additionally, using a builder approach allows you to streamline the issue creation and linking process, making it easier to troubleshoot if something goes wrong.