How to use REST API to add remote links in JIRA issues
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article explains the JSON data structure needed to add remote links , including link to confluence pages, to an existent JIRA issue using the remoteLink Rest API .
Solution
Add Web Link
To create a Web Link to an issue you will need the URL to be linked and the Link Text (title) to be displayed for the Web Link , this information will be used to build the JSON blob used on to run the POST /rest/api/2/issue/{issueIdOrKey}/remotelink command , below is an example for this command :
Example: Here remoteLink.json exist in same location where we invoke remoteLink REST operation using curl command.
$ cat remoteLink.json { "object": { "url": "https://www.atlassian.com/software/jira", "title": "Jira Software Page" } } $ curl -u "username:password" -XPOST -H "Content-Type: application/json" -d @remoteLink.json 'http://localhost:8080/rest/api/latest/issue/SAMPLE-1/remotelink'
đź’ˇMore information on the JSON fields can be found at Using fields in Remote Issue Links .
Add Confluence Link
To create a Confluence link you will need the same information as for the Web Link , plus the information of the Application for the link and to generate the a globalId for the page to be linked to .
The Application in this case will be confluence and its declaration for all links is static as per provided example JSON
The globalId is a string composed of the application ID (appId=) inside Jira that refers to its application link connection with confluence and the confluence page ID (pageId=) .
The application ID can be retrieved from the URL of the application link edit page , by following the below steps
Go to Administration
> Applications > Application Links and click on the Edit (
) icon on the Confluence configuration line
On the new loaded page you can retrieve the application ID from its URL as per below example:
http://localhost:8080/plugins/servlet/applinks/edit/<confluence_application_link_id>
The Confluence page ID can be retrieved inside confluence using the KB How to get Confluence page ID
This information will be used to build the JSON blob used on to run the POST /rest/api/2/issue/{issueIdOrKey}/remotelink command , below is an example for this command :
Example: Here remoteLink.json exist in same location where we invoke remoteLink REST operation using curl command.
$ cat remoteLink.json { "globalId": "appId=43d21959-661d-36dc-a836-debca302edd7&pageId=98320", "application": { "type": "com.atlassian.confluence", "name": "Confluence" }, "object": { "url": "http://localhost:8090/pages/viewpage.action?pageId=98320", "title": "Wiki Page" } } $ curl -u "username:password" -XPOST -H "Content-Type: application/json" -d @remoteLink.json 'http://localhost:8080/rest/api/latest/issue/SAMPLE-1/remotelink'
Was this helpful?