Dear Community,
After linking a Jira Cloud project with a Confluence space (Project pages -> Connect), how can I query the key/id of the associated Confluence space using the Jira (or Confluence) REST API?
Many thanks!
There isn't a way to get this from the REST API that I am aware of but you can get it through the Atlassian GraphQL gateway with a couple of queries:
query GetAllJiraProjects( $cloudId: ID!, $first: Int, $after: String ) { jira { allJiraProjects( cloudId: $cloudId, filter: {}, first: $first, after: $after ) { edges { node { id name } } pageInfo { hasNextPage endCursor } } } }
query GetConnectedConfluenceSpaces($projectARI: ID!) { devOps { ariGraph { relationships( filter: {from: $projectARI, type: "project-documentation-entity"} sort: {lastUpdatedSortDirection: DESC} ) { nodes { to { id data { ... on ConfluenceSpace { id name } } } } } } } }
Variables:
Hi @Peter Velosy my name is Habib I shall do my best to help you with the question.
To query the key/id of the associated Confluence space using the Jira or Confluence REST API, follow these steps:
1. First, obtain the Jira Cloud project key and the Confluence Cloud space key.
2. Make a GET request to the Jira REST API endpoint that returns information about the project. The endpoint is in the following format:
```
https://your-domain.atlassian.net/rest/api/2/project/{projectKey}
```
Replace `{projectKey}` with the actual key of your Jira Cloud project.
3. In the response, look for a field called `projectCategory`. This field contains a nested object with a `projectCategoryKey` field. The value of `projectCategoryKey` is the key of the Confluence Cloud space associated with the Jira Cloud project.
4. Make a GET request to the Confluence REST API endpoint that returns information about the space. The endpoint is in the following format:
```
https://your-domain.atlassian.net/wiki/rest/api/space/{spaceKey}
```
Replace `{spaceKey}` with the actual key of your Confluence Cloud space.
5. In the response, look for a field called `key`. The value of `key` is the key of the Confluence Cloud space associated with the Jira Cloud project.
Alternatively, you can also use the Jira REST API to get the Confluence space key by making a GET request to the following endpoint:
```
https://your-domain.atlassian.net/rest/jira/latest/project/{projectKey}/properties/confluenceHome
```
Replace `{projectKey}` with the actual key of your Jira Cloud project.
The response will contain a `value` field, which is a URL that points to the Confluence Cloud space homepage. The space key is the last part of the URL, after the `/display/` path.
I hope this helps.
thank you
Habib
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Project Category is a different entity than the Confluence space associated with the Jira project. Maybe in your case, the two ID-s accidentally match up, but this is not the case on my end.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By the way, I have a strong suspect that you (provided that you are a human at all) generated this response with ChatGPT. Please refrain from spamming this expert forum this way. If you are a human who uses ChatGPT for researching information, please double-check if the response is correct and if it makes sense, as it is often not the case with language models.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.