Another as of yet undocumented and thus possibly unsupported option:
I recently noticed that the GraphQL Gateway provides a tenantContexts
GraphQL query which can be used to infer the site URL from the cloudId
and vice versa, and it works for both Jira and Confluence:
A Jira or Confluence cloud instance, such as
hello.atlassian.net
has a backing cloud ID such as0ee6b491-5425-4f19-a71e-2486784ad694
This field allows you to look up the cloud IDs or host names of tenanted applications such as Jira or Confluence.
You MUST provide a list of cloud IDs or a list of host names to look up but not both otherwise an error will be returned
Here’s an example query:
query tenantContexts($cloudIds: [ID!]) {
tenantContexts(cloudIds: $cloudIds) {
cloudId
hostName
}
}
Providing a cloud ID from the useProductContext() hook yields e.g.:
{
"data": {
"tenantContexts": [
{
"cloudId": "2ef567f6-17c6-421f-a6cc-2fb075be8be6",
"hostName": "utoolity.atlassian.net"
}
]
},
...
}
@danielwinterw - I realize that the GraphQL API is not yet officially supported, but given Forge uses it heavily and the product fetch API just gaining a (so far undocumented) requestGraph()
method, can you maybe sneak peek indicate whether this might be a stable approach already?