Add Existing Confluence page to Jira using REST API

I have created a confluence page related to a jira issue and now I want to link the created confluence page to the respective jira which I can do as below, but how can I do the same using REST API?

You can use: POST/rest/api/3/issue/{issueIdOrKey}/remotelink (Create or update remote issue link)
The content should look like this:

{
    "globalId": "appId=<app-link-id>&pageId=<page-id>",
    "application": {
      "type": "com.atlassian.confluence",
      "name": "Confluence"
    },
    "relationship": "Wiki Page",
    "object": {
      "url": "<base URL>/wiki/pages/viewpage.action?pageId=<page-id>",
      "title": "Wiki Page",
    }
  }

Replace <page-id> (in two locations) with the ID of the page (or blog post) and <app-link-id> with the ID of the application link. You can find the ID of the app link by calling /rest/applinks/3.0/listApplicationlinks. FYI apps don’t have access to the list of app links.

1 Like

That would be the exact answer I was looking for! Thank you :smile:

But one question here “FYI apps don’t have access to the list of app links.” by this do you mean I can’t call the API using forge? And if No then what is the way to get just the application id?

do you mean I can’t call the API using forge?

Yes that is what it means. I’ve only tested it with a Connect app, but I’m pretty sure a Forge app wont be able to access it, as it is not part of the official API.

As a workaround we have added a link to this REST call and an input to our configuration page where an admin has to manually paste the app link ID.