Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of contents

Table of Contents
maxLevel2

Introduction

...

Our plugin allows you to change

...

its data via Atlassian API. We use the properties of the issue so you can get, update, delete or create data outside of the plugin UI.


You can preview the data by making a GET request to: https://{ site-url }.atlassian.net/rest/api/2/issue/{ issue.id }/properties/sd-checklists-0

PUT requests are also made to the same endpoint.

If you have a lot of checklists, you may need to call GET

Code Block
https://{ site-url }.atlassian.net/rest/api/2/issue/{ issue.id }/properties

to check if there are properties like sd-checklists-1, sd-checklists-2 that contain checklists that did not fit into sd-checklists-0


If your project permission is not set to "anyone" you will need an API Token. You can generate it here: https://id.atlassian.com/manage/api-tokens

After acquiring it you will be able to use the API as long as your account have has sufficient permissions.


Below you can find examples using curl and postman, but first, let's check the checklist data structure.

...

We store an array of checklists for every issue separately. Each checklist have has an id, name, and an array of items.

You should always set the version to 1.0.0. It is here to help us detect the version of the checklist our client is using.

...

https://{ site-url }.atlassian.net/rest/api/2/issue/{ issue.id }/properties/sd-checklists-0 - read/update/delete the checklist

...

Code Block
languagebash
firstline1
linenumberstrue
curl -u { your email }:{ your API token } https://{ site-url }.atlassian.net/rest/api/2/issue/{ issue.id }/properties/sd-checklists-0

How to add/update checklist:

...

Code Block
languagebash
firstline1
linenumberstrue
curl -X PUT -H "Content-Type: application/json" -u { your email }:{ your API token } https://{ site-url }.atlassian.net/rest/api/2/issue/{ issue.id }/properties/sd-checklists-0 -d '{
   "version":"1.0.0",
   "checklists":[
      {
         "id":0,
         "name":"Example to do",
         "items":[
            {
               "name":"<p>task 1</p>",
               "required":true,
               "completed":true,
               "status":0,
               "user":"{ user id }",
               "date":"2019-08-13T13:18:24.046Z"
            },
            {
               "name":"<p>task 2</p>",
               "required":false,
               "completed":true,
               "status":0,
               "user":"{ user id }",
               "date":"2019-08-13T13:18:44.988Z"
            },
            {
               "name":"<p>task 3</p>",
               "required":false,
               "completed":false,
               "status":0,
               "user":"{ user id }",
               "date":"2019-08-08T13:30:29.643Z"
            }
         ]
      }
   ]
}'

...

Code Block
languagejs
linenumberstrue
curl -X PUT -H "Content-Type: application/json" -u { your email }:{ your API token } https://{ site-url }.atlassian.net/rest/api/2/issue/{ issue.id }/properties/sd-checklists-0 -d '{}'


Examples with Postman:

...

To make a GET request you need to set a basic auth with your email and API token. Header The header will be generated automatically. Check the screenshot below for an example.:

How to update data:

To make a PUT request you need to set a header, basic auth with your email and API token, and body with data. Check the screenshot below for an example.: