UI Kit components
UI Kit hooks
Forge bridge APIs
Jira bridge APIs
Upgrade UI Kit versions
Previous versions

invokeRemote

The invokeRemote bridge method enables apps to integrate with remote backends hosted outside the Atlassian platform.

To use the invokeRemote bridge method, you need to define an endpoint for your back end in the manifest.yml file.

Function signature

1
2
interface InvokeRemoteInput {
  path: string;
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
  headers?: Record<string, string>;
  body?: unknown;
}

function invokeRemote(
  input: InvokeRemoteInput
): Promise<{ [key: string]: any } | void>;

Arguments

  • path: The path that will be appended to the baseUrl of the remote.
  • method: The HTTP method for the request.
  • headers: Optional custom headers that you can add to your request.
  • body: The body of your request.

Returns

A Promise that resolves with the data returned from the invoked endpoint:

  • The content-type header must be application/json.
  • The Promise will reject if the invoked endpoint returns a non-JSON response.
  • The Promise will reject if the invoked endpoint returns a non-2xx status code.
  • The HTTP status code from the response will not be available in the Promise.
  • The headers from sucessful responses will be available in the headers properties.

Example

Making a POST request to a remote endpoint:

1
2
import { invokeRemote } from "@forge/bridge";

const res = await invokeRemote({
  path: `/tasks/`,
  method: 'POST',
  headers: {
    x-header-key: 'x-header-value',
  },
  body: {
    department: 'Ecosystem',
    team: 'Forge',
    description: 'Write docs'
  }
});

console.log(`Created task: ${JSON.stringify(res.task)}`);

Making a GET request to a remote endpoint:

1
2
import { invokeRemote } from "@forge/bridge";

const res = await invokeRemote({
  path: `/tasks/?team=Forge`,
  method: 'GET'
});

console.log(`Tasks: ${JSON.stringify(res.body[0])}`);

Rate this page: