Also, you can get the URL/URI from the HTTP request itself inside the controller of the framework you use (e.g. Connect for Express or Connect for Spring ) and pass it to the UI model of the templating language you use.
We asked about this in the decommissioned Forge Slack channel and got advise from the Forge team how to deduce the site information, though it turned out to be only applicable for Jira and not Confluence at the time (right now you can still apply the Jira approach on Confluence because Forge is not enabled for Confluence only sites).
Unfortunately I’ve misplaced my notes and cannot recall the details right now - will reply once more in case I find/recall those.
I do recall our workaround though, which is based on Tim Pettersen’s clever answer to Status URL for monitoring?:
There isn’t a formal status API that I’m aware of, but the AppLinks Manifest end-point is a good URL you can hit for most of our products (JIRA, Confluence, Stash, Bamboo, FishEye and Crucible). If it returns a 200, your server is probably in good shape.
It does not require authentication and is available at:
I can jump in on that - the Jira only, slightly more explicit approach uses the baseUrl entry from /rest/api/3/serverInfo, e.g.:
export const getEnvironmentBaseUrl = async () => {
let result;
// NOTE/KLUDGE: We have no proper approach for Confluence so far, but can currently rely on a Confluence instance always having a
// corresponding Jira instance, hence using the respective Jira pproach only for starters:
//const hostProduct = getHostProduct();
const hostProduct = "jira";
if (hostProduct === "jira") {
result = await api
.asApp()
.requestJira("/rest/api/3/serverInfo");
const serverInfo = await result.json();
result = serverInfo.baseUrl;
}
// TODO: Add Confluence specific version, once available
return result;
}
(left the preparation and notes on the Confluence topic, easy to shorten for a Jira only situation, of course)
Would you mind describing a little about what you need this for? That way I can take it back to my team. We are still working on Forge context so any input is valuable
Yes. I want to send to a backend system information about work logs. But the same organization might use several instances of jira cloud so I want to identify the remote worklog (i.e. Jira worklog) by: instance, issue, worklog.id so I can send back API requests to alter these work logs if the backend system finds incompatibilities with org rules.
I assume that this system would be your own external API? Could you use another identifier like installationContext for that? I’m curious to understand why it needs to be the site URL itself given that it is not required for calling the APIs from Forge?
Because I needed to go async at my external app, I have to return some confirmation after I finish processing the job. I am returning this via API directly to Jira cloud (skipping the Forge app completely) from my own external app, hence I need the full URL.
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 as 0ee6b491-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
@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?
This is actually a pretty awesome find. Using a graphql client like “graphql-request” it is possible to fetch an instances hostName by providing its cloudId which is available via forgeContext.
Is there really no simple and official way to get the Jira BaseURL in Forge? @danielwinterw
I need to get the baseUrl to create a simple Issue Link to display to end users, which is impossible because the RestAPI returns the “self” link of the issue as https://api.atlassian.com/ex/... - My context is a web trigger.
Hi @denizoguz - Good news. The problem seems fixed now. Unfortunately, we don’t have any info from support if they identified the issue or if it was temporary. Will update you here in case of more information. Looking forward to hearing all works fine on your end too. Greetings!
Hi @LukasGotter
Thanks a lot. It is working for us too now. It was something temporary with Forge backend. Because it was working when we call it from a browser.