api.requestJira across domains

Hi,

I’m trying to make a confluence plugin to show data based on JIRA issues across multiple domains ({domain}.atlassian.net)

This is my first app in Forge, so please help a rookie out…

I notice that the requestJira examples use this format, where we’re assuming that we’re looking within the same domain:

requestJira('/rest/api/3/issue/ISSUE-1');

I took the approach of just inserting the new domain in front, but get a 404 with teh following log (I output the entire url that i is passed as first parameter to the requestJira method):

INFO    12:22:53.398  8596d4aa6f154673  request url: https://my-other-domain.atlassian.net/rest/api/2/search?jql=key=CRM-32
INFO    12:22:53.747  8596d4aa6f154673  Response: 404 Not Found
INFO    12:22:53.747  8596d4aa6f154673  {
  timestamp: '2022-11-25T12:22:54.010698Z',
  status: 404,
  error: 'Not Found',
  message: 'No message available',
  path: '/ex/jira/16ff9f83-b012-45bf-b9f1-02ccda3b5cb4https:/my-other-domain.atlassian.net/rest/api/2/search'
}

This is the function i’ve created to request issues from a domain with jql query:

const fetchIssuesFromJQL = async (host, jql) => {
  console.log(`request url: ${host}/rest/api/2/search?jql=${jql}`);
  const res = await api
    .asUser()
    .requestJira(route`${host}/rest/api/2/search?jql=${jql}`);

  
  console.log(`Response: ${res.status} ${res.statusText}`);
  
  const data = await res.json();
  return data;
};

Taking the URL that I put into the requestJira, and just pasting it onto the browser, i get the REST result i expect

Cannot figure out how to do this, hope someone can help?

Forge doesn’t run in your browser, and so does not have credentials to access the other instance. In short, you can’t access another instance from Forge directly.