i would like to link a confluence page to a jira issue via rest api from a jira cloud/server app. apparently there is no documentation yet but i noticed a jira-confluence link is created by the remotelink endpoint.
i tried the following:
const data = {
object: {
url:properties.pageUrl,
title:properties.pageTitle || 'Flower Confluence Link'
},
application: {type: 'com.atlassian.confluence', name: 'System Confluence'},
globalId: 'appId=' + '6dd09426-cc5c-48f6-bfff-4c3e7e5a11dc')+ '&pageId=' + properties.pageId,
relationship: 'Wiki Page'
}
return http.post(config.jira.rest.base + 'issue/' + properties.issueKey + '/remotelink', data);
which worked basically - but from where do i get the confluence-appId??
i tried:
http.get(config.confluence.rest.base + 'settings/systemInfo')
which would be the solution - but a jira-app is not allowed to access a confluence service..
but apart of this - is there another best practice approach - something simpler like
linkIssueWithConfluence(issue-key,page-id);
Welcome!
You're quite right, there is virtually no documentation on how to obtain the applicationID of a Confluence instance in all situations. The below solution requires that you have an application link created between the Confluence Cloud and Jira Cloud instance, and it's also quite brittle, since it relies on V1 of the REST API that certainly has no guarantee of continued support - but I've been pondering this one for a week now and I can't figure out any alternatives.
Using the Jira Cloud REST API call http://SITE_NAME.atlassian.net/rest/applinks/1.0/listApplicationlinks, you can then use xPath or JSONPath or whatever libraries you have at your exposure to get at the application ID. You'll need to insert logic to parse all defined application links in the event that there are multiple, but the typeId should specify whether the application link is for Confluence or another product.
Unfortunately, there is no best practice here to define remote issue links other than through the remotelink endpoint you've identified, which requires the globalId to be defined through the appId and pageId.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.