API and Automation

image-20240120-110005.png

Demo Video https://www.youtube.com/watch?v=Bdd6J_KnUIo

Pre-condition

  1. Navigate to Manage Apps

  2. Click on Configure button on Macro for Assets

  3. Click on API tab

  4. Click Generate Access Token

  5. Copy the token and the URL you will need them when configure web requests

 

Create a Template page

  1. Create a new Page in Confluence

  2. Add the Macro for Assets

  3. Configure it as you like the table to look like when new objects are added

  4. Save the macro

Get the Template page configuration

From any rest tool, example postman send a GET request to get the config of the configured Macro above.

  1. In postman, select Method GET

  2. Past the URL from pre-condition step into URL field

  3. On Params tab add;

    1. Key as token and Value paste token from pre-condition

    2. Key as pageId and Value paste page id of the Template page created in this step

  4. Click Send

  5. View the response, copy that, you will need it in the next tutorial

Use case 1. Create Page when New object has been created

  1. Navigate to Global Automation at instance_url/jira/settings/automation

  2. Click Create

  3. Select Trigger Object

  4. Add component, select THEN action

  5. Select Send web request

  6. Paste the copied URL from pre-condition into Web request url field

  7. Add ?token=<<<token from pre-condition>>>&spaceKey=<<<THE_SPACEKEY>>>

  8. Select Method POST

  9. Select Custom Data

  10. Add the following body, it will create a Page with the same name as the object

    [ { "title":"{{object.name}}", "parentPageId":"", "macros":<<<MACRO_CONFIG_GOES_HERE>>> } ]
  11. Paste the response from the Get template configuration step (e.g. REST request) in the <<<MACRO_CONFIG_GOES_HERE>>> part of the above code.

    [ { "title":"{{object.name}}", "parentPageId":"", "macros":[ { "id": "THIS_CAN_BE_BLANK", "configuration": { "columns": [], "iql": "key={{object.key}}", "displayAs": "AS_VERTICAL_TABLE", "pageSize": 25, "schemaId": "6", "connectionId": "45157a8a-79ad-46f7-b920-c21211bf79ec" } } ] } ]
  12. Click Turn on Rule

  13. Name the rule something, lets call it Create page from object.

Use case 2. Copy Page when New object has been created

  1. Navigate to Global Automation at instance_url/jira/settings/automation

  2. Click Create

  3. Select Trigger Object

  4. Add component, select THEN action

  5. Select Send web request

  6. Paste the copied URL from pre-condition into Web request url field

  7. Add ?token=<<<token from pre-condition>>>&spaceKey=<<<THE_SPACEKEY>>>&pageId=<<<THE_PAGE_ID_TO_COPY>>>

  8. Select Method PATCH

  9. Select Custom Data

  10. Add the following body, it will create a Page with the same name as the object

    [ { "title":"{{object.name}}", "parentPageId":"", "macros":<<<MACRO_CONFIG_GOES_HERE>>> } ]
  11. Paste the response from the Get template configuration step (e.g. REST request) in the <<<MACRO_CONFIG_GOES_HERE>>> part of the above code.

  12. Click Turn on Rule

  13. Name the rule something, lets call it Create page from object.

Test the setup

  1. Create an Object

  2. This will now call the automation that will result in create a new Page with the macro config. Depending on use case it can be a blank page or a copy of a page



 

Â