Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
callRest
callRest
This is a custom Nunjucks filter that makes an http(s) call to an external REST API. It operates on a string representing the REST API endpoint to call, and it returns the response as JSON (unless customized using the noJSON parameter)
To make a call to any Jira Cloud REST API on the current Jira instance then use callJira() filter
On this page:
Applies to
A string representing the REST API endpoint to call. For example "https://reqres.in/api/users"
. Note it can also be another Jira instance like https://example.atlassian.net/
Parameters
Note the use of named parameters instead of positional parameters because of the number of parameters and their optional nature.
Named parameter | Description | Examples |
---|---|---|
| Indicates the HTTP verb such as GET (to get information), PUT (to update existing information), POST (to post or create a new item), DELETE (to delete an item). The default is The verb is not case-sensitive. |
updates the first name of the user whose id is
creates a new user in the rest API
|
| Indicates the parameters to be passed to replace placeholders in the rest-url. It is a hash of key and values. Any instance of ":key" in the The default is no param |
|
| Indicates the query parameters to be added to the http call. It is a hash of key and values. The values must be scalar and will be encoded appropriately. This is used to return a subset of fields. The default is no query param. |
|
| Indicates the body to pass to The default is no body. | {{ "https://reqres.in/api/users" | callRest( verb="post",
body={
"name": "morpheus",
"job": "leader"
}) }} creates a new user in the API with the information provided in the body |
| Indicates the options passed to the "request" call. It can be used in particular to pass authentication information (see https://www.npmjs.com/package/request#http-authentication) but many other options are supported (see https://www.npmjs.com/package/request#requestoptions-callback for the entire list). The default is no option. | dumps the information of the issue with key TEST-1 operating with the provided authentication information. |
| Controls the response format. If The default is | dumps the response as plain text. |
| If |
|
| If The following IP addresses are used:
The default is |
Examples
Here are a few examples using the callRest
filter
Get the information from an API
Gets the information of a user with id 2
and outputs the information in a pretty JSON format with 2 spaces indentation.
Get issue information from another Jira instance
Using this filter you can make calls to another Jira instance. You will need to authenticate using the username (one used to log in to the instance) and password (the API token created for the destination instance).
dumps the details of the issue with key TEST-1 using the provided authentication information.
Convert the amount in a custom field to a specific currency
returns the amount in the custom field in INR currency.