Rate this page:
Forge API product fetch is a partial implementation of node-fetch and includes an
Authorization
header based on the context-bound fetch call.
Import the Forge API package in your app, as follows:
1
import api from '@forge/api';
To check the status of a request, use status
as shown below:
1 2 3 4 5 6
const result = await api
.asApp()
.[requestConfluence | requestJira](
`/rest/api/`
);
const status = result.status;
See the Options section of the node-fetch documentation on GitHub for full implementation details.
1 2 3 4
api.[contextMethod](): <{
requestConfluence,
requestJira,
}>
Method | Description |
---|---|
api.asApp() | Use this method to call an Atlassian API as the app developer. |
api.asUser() |
Use this method to call an Atlassian API as the user of the app. If the user initiating the request has not granted permission to the app, the request is made without a valid If the API returns a
Note: This context method is only available in modules that support the UI kit. |
Makes a request to the Confluence REST API.
1 2 3 4 5
// Authenticated
api.[asApp | asUser]().requestConfluence(path[, options]) => Promise<Response>
// Unauthenticated (used for operations that do not support OAuth 2.0)
api.requestConfluence(path[, options]) => Promise<Response>
Name | Type | Description |
---|---|---|
path | string | A Confluence REST API operation path. See the Confluence Cloud platform REST API for more information. |
options | object | See the node-fetch library’s Options documentation for the accepted values. Defaults: |
Make a request to the /rest/api/content
resource on the Confluence site
where the app is installed.
1
api.[asApp | asUser]().requestConfluence('/rest/api/content');
Make a request to the /rest/api/audit
resource on the Confluence site where
the app is installed, using basic authentication.
1 2 3 4 5
api.requestConfluence('/rest/api/audit', {
headers: {
'Authorization': 'Basic <base64 token>'
}
});
Makes a request to the Jira REST API.
1 2 3 4 5
// Authenticated
api.[asApp | asUser]().requestJira(path[, options]) => Promise<Response>
// Unauthenticated (used for operations that do not support OAuth 2.0)
api.requestJira(path[, options]) => Promise<Response>
Name | Type | Description |
---|---|---|
path | string | A Jira REST API operation path. See the Jira Cloud platform REST API for more information. |
options | object | See the node-fetch library’s Options documentation for the accepted values. Defaults: |
Make a request to the /rest/api/2/myself
resource on the Jira site where the app is installed.
1
api.[asApp | asUser]().requestJira('/rest/api/2/myself');
Make a request to the /rest/api/2/auditing/record
resource on the Jira site where
the app is installed, using basic authentication.
1 2 3 4 5
api.requestJira('/rest/api/2/auditing/record', {
headers: {
'Authorization': 'Basic <base64 token>'
}
});
Rate this page: