---
title: "Create Confluence pages from Jira transitions with REST calls"
canonical: "https://support.appfire.com/space/EI4J/11206826/Create%20Confluence%20pages%20from%20Jira%20transitions%20with%20REST%20calls"
format: markdown
---
> Macro (aura-html)

Easy Integrations allows you to automatically generate Confluence pages based on Jira workflow transitions. 

This document guides you through configuring the **Create Confluence Page using a template page** post function.

## Step 1: Add the post function

1. Go to the desired transition of your workflow, switch to the **Post functions** tab, and click the **Add post function **link.
2. Locate the **EIS - Create Confluence Page using a template page** post function.
3. Click on the **Add** button.

## Step 2: Post function name 

4. Give your post function a descriptive name.

## Step 3: Create script condition6. 

5. You can create a decision to execute the REST according to the result of Groovy script. By default, it can only **return true** statement. However, you can type your script and **return true;** to execute REST, or **return false;** to not execute. Here is a sample code of how you can type your own script:

![image-20240814-103135.png](media://89f8c4d6-6f8b-4e0d-ae4a-79a27beb3058)

Condition code example:

```
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser log.info("current user:" + currentUser.username) def reporter = issue.reporter.username log.info("reporter: " + reporter) return reporter.equals(currentUser.username)
```

## Step 4: Fill in REST service details 

In this section, REST details are filled:

6. **URL** – The URL of the REST service. You can define any dynamic parameter here using double curly braces (for example, [http://mycompany.com/api/book/{{bookId](#)}} assuming bookId is defined in the Parameters section, which is described below).
7. **Method** – Select HTTP Method (GET, POST, PUT, DELETE).
8. **Headers** – Define your HTTP header key/value sets on separate lines.
9. **Request Body** – Type json request body. You can use dynamic parameters here as well.

```plaintext
{ "assignee" : "{{assignee}}", "reporter" : "{{reporter}}", "userName" : "{{userDisplayName}}", "price" : "{{price}}" }
```

10. <span style="color: #000000">**Parameters**</span><span style="color: #000000">: Define all of your dynamic parameters here using Groovy Script. You can add static values as well as the dynamic values of fields/custom fields in the Jira issue. Here are some sample usages:</span>

```groovy
def parameters = [:] parameters["assignee"] = issue.assignee parameters["reporter"] = issue.reporter def userManager = ComponentAccessor.getUserManager() parameters["userDisplayName"] = userManager.getUserByName("someUserName").getDisplayName() def cf = customFieldManager.getCustomFieldObject("customfield_xxxxx") def price = issue.getCustomFieldValue(cf) parameters["price"] = (null != price) ? price : "No price defined" return parameters
```

> 📝 <span style="color: #000000">For more details about parameter assigning and utils, see the </span>[Parameter Usages](https://appfire.atlassian.net/wiki/spaces/EI4J/pages/11206752) page<span style="color: #000000">.</span>  
> 📝 <span style="color: #000000">Also see</span> the [ComponentAccessor](https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/component/ComponentAccessor.html)<span style="color: #000000">,</span> [User](https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/user/ApplicationUser.html), [Issue](https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/issue/Issue.html), <span style="color: #000000">and</span> [Status](https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/issue/status/Status.html) <span style="color: #000000">API pages for all properties and methods.</span>

11. <span style="color: #000000">**Authorization Type**</span><span style="color: #000000">: Choose authorization type - currently BASIC Authentication is supported.</span>
12. <span style="color: #000000">**Credential**</span><span style="color: #000000">: If you choose any Authorization Type, this option becomes active and the credentials you defined in the</span> [Credentials](https://appfire.atlassian.net/wiki/spaces/EI4J/pages/11206862)<span style="color: #000000"> section will be listed. Below is an example:</span>

## Step 5: Configure a post function

<span style="color: #000000">In this section, you can optionally configure the post function to update a custom field based on a value in the REST response.</span>

13. Check the **Update custom field** box to update a custom field based on the REST response.
14. Select the custom field you want to update from the dropdown.
15. Enter a **JSONPath** expression to specify the value within the response to update the field with. Leave empty if you want to use the entire response body. For JSONPath examples, see the [JSONPath examples](https://appfire.atlassian.net/wiki/spaces/EI4J/pages/11206873) page.

## Step 6: Run asynchronously

16. <span style="color: #000000">In this section, you can optionally enable async to execute the REST service asynchronously. There are a couple of reasons why you may want to execute asynchronously:</span>
  - <span style="color: #000000">Executing synchronously makes the user wait for the transition longer than usual. If the REST service host responds late or there is a connection timeout between the Jira server and the host, the user will wait for the spinner for a long time. So, it may be wise to enable async if your REST service responds slowly.</span>
  - <span style="color: #000000">Some issue parameters may wait for calculation or reindexing. Some plugins may work in the background to populate the actual result of a custom field and you may want to use that value. </span>

> 📝 A scheduled task titled **Easy Integrations for Jira - Async Rest Caller Scheduled Task** is set to run every 2 minutes. This task is responsible for monitoring specific REST calls and carrying out the necessary executions.

### Step 7: Publish the workflow

17. Save your changes to the workflow.
18. Publish the workflow for the changes to take effect.

### Order of execution 

<span style="color: #000000">The order of the REST Service Caller post function is very important and depends on what you want to do. </span>

![image](media://17b10137-5f2f-4822-867f-865b3c5f612f)

<span style="color: #000000">If the REST Service Caller post function is </span><span style="color: #000000">**BEFORE**</span><span style="color: #000000"> the </span>`Update change history for an issue and store the issue in the database`<span style="color: #000000"> post function:</span>

- `$issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123')) `<span style="color: #000000">call returns the </span><span style="color: #000000">**old**</span><span style="color: #000000"> value of </span>`customfield_10123`<span style="color: #000000">.</span>
- `$transientIssue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123')) `<span style="color: #000000">call returns the new value of </span>`customfield_10123`.
- <span style="color: #000000">If the </span><span style="color: #000000">**Update custom field**</span><span style="color: #000000"> is selected, the custom field(s) will be updated successfully.</span>

<span style="color: #000000">If the REST Service Caller post function is </span><span style="color: #000000">**AFTER**</span><span style="color: #000000"> the </span>`Update change history for an issue and store the issue in the database`<span style="color: #000000"> post function:</span>

- `$issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123')) `<span style="color: #000000">call returns the </span><span style="color: #000000">**new**</span><span style="color: #000000"> value of </span>`customfield_10123`.
- <span style="color: #000000">If the </span><span style="color: #000000">**Update custom field**</span><span style="color: #000000"> is selected, the custom field(s) will not be updated successfully as the </span>`Update change history and store the issue in the database`<span style="color: #000000">** **</span><span style="color: #000000">post function is already executed.</span>