Creating JIRA tickets with checklist fields via the API

Matt Decker February 22, 2016

Hello,
I am programmatically creating issues via the JIRA API. These issues have Definition of Done and Acceptance criteria fields which are checklists.

I add the following to my API calls

"customfield_10306": "Security updates applied",
"customfield_10325": "Security updates deployed to production"

and get the following error:

{"issues":[],"errors":[{"status":400,"elementErrors":{"errorMessages":[],"errors":{"customfield_10306":"Not a valid JSON object","customfield_10325":"Not a valid JSON object"}},"failedElementNumber":0}]}

How does one create JIRA tickets via the API that contain items within checklist fields?

Thanks!

 

Additional Info:

Version Numbers:

  • JIRA 7.0.10
  • Checklist v3.1.1.

{ "issueUpdates": [{
        "fields": {
           "project":
           {
              "key": "QB"
           },
           "summary": "81.80 | ./old.cs10kcommunity_org",
           "description": " Drupal  6.34               6.37              SECURITY UPDATE available ",
           "issuetype": {
              "name": "Task"
           },
           "customfield_10306": "Security updates applied",
           "customfield_10325": "Security updates deployed to production",
           "timetracking":
            {
               "originalEstimate": "2h",
               "remainingEstimate": "2h"
            }
       }
    }
]}
https://jira.domainname.com/rest/api/2/issue/bulk

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 22, 2016

@M.Decker,

I spent some time looking into it. I was able to create one item. The thing is that the JSON object needs to be encoded into a string so what worked is this:

"customfield_10306": "{\"name\": \"Security updates applied\"}"

The problem is that it will only allow you to create one item. Checklist does not implement the REST interface required to use a JSON object so JIRA falls back to using a string and does its own thing, never actually calling the Checklist field.

So, in order for this to work properly, Checklist needs to implement the REST interfaces. I will put that in our backlog.

Otherwise, it may be feasible posting form data to the url http://localhost:2990/jira/secure/AjaxIssueAction.jspa?decorator=none. This is how JIRA seems to be doing its inline edit. If you monitor the network action in chrome when saving a Checklist from the inline edit mode, you will have an example of the data that is being sent via the form data. However, not sure that it could work because of the session ID.

 

Matt Decker February 23, 2016

That works perfectly; thanks!

Jeff_Maes April 25, 2016

Hi, any idea if this issue will be resolved on a short term?

@M.Decker, did you succeed using the AjaxIssueAction? I always receive an jira XSRF Security Token exception. Or did you disabled that?

Using JIRA v7.1.2

Camille Martel May 4, 2016

@@Jeff Maes: I just managed to update a checklist using the AjaxIssueAction request. As @Whyves suggests, I used Chrome inspector to look at the request being sent along with the cookies. I then fabricated a POST request using python requests and supplied it with these cookies:

atlassian.xsrf.token 

JSESSIONID

and the following request payload:

[('issueId', u'10479'),
('atl_token',
'<YOUR XSRF TOKEN HERE>'),
('singleFieldEdit', True),
('customfield_10101',
'{"mandatory": true, "checked": true, "name": "Arf", "rank": 1, "id": -1}'),
('customfield_10101',
'{"mandatory": true, "checked": false, "name": "Foo", "rank": 2, "id": -2}'),
('customfield_10101',
'{"mandatory": true, "checked": true, "name": "Bar", "rank": 3, "id": -3}')]

0 votes
Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 22, 2016

Hi,

I have actually never tried via the JIRA API but if you want to create items try:

 

"customfield_10306": [{"name": "Security updates applied"}],
"customfield_10325": [{"name": "Security updates deployed to production"}]
You should also be able to add properties such as "checked" and "mandatory" in the json structure if you want to set the checked state ("checked": true) and/or make an item mandatory ("mandatory": true) or optional ("mandatory" : false)
Matt Decker February 22, 2016

Thanks for the quick feedback.

This is the error I receive using the format above:

{"issues":[],"errors":[{"status":400,"elementErrors":{"errorMessages":[],"errors":{"customfield_10306":"Operation value must be a string"}},"failedElementNumber":0}]}

Submitting an array returns "Operation value must be a string." while submitting a string return "Not a valid JSON object".


We're running JIRA 7.0.10 and Checklist v3.1.1.

Philip Colmer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2017

@Whyves do you know when Checklist might get support via the REST API, please?

 

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 17, 2017

@Philip Colmer, I'm starting working on a new version which will support REST endpoints. I hope to release it in a few weeks.

Timothy Lusk May 22, 2017

@Whyves any update on the new version supporting REST endpoints?

 

Thanks!

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 22, 2017

@Timothy Lusk, I have actually implemented it but I need to work on other features of the add-on before releasing it as I want to make a major release. Hopefully in a few weeks.

Timothy Lusk July 25, 2017

@Yves Riel [Okapya] any new updates on that major release?

Thanks!

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 25, 2017

Hi Timothy,

Sorry, we had to postpone the new version for a few months. We should go back at it at the end of the summer and release it early fall ... hopefully.

I appologize for any inconvenient

Mike Sullivan November 27, 2017

@Yves Riel [Okapya] Not to be a pest, but do you have any updates on this?  I saw you released a cloud version this month, did that have the API updates?  Do you know when you will release the server version with these changes?

We run JIRA 7.5.1 and Checklist 3.1.13

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
November 29, 2017

@Mike Sullivan, you're not being a pest :-) I don't really want to commit to a specific date for the moment. We're working on it but it's not going as fast as I would have hoped for. We were able to implement the REST interface and it seems to work but the new version also has other major refactoring and they're not ready so I cannot release it now ... maybe in next year's first quarter.

I really apologize for the too long delays :-(

Stephen Johnson April 18, 2018

@Yves Riel [Okapya], wanted to follow up and see if there is any update on this?

 

Edit: Never mind my question and good news for all:

https://okapya.atlassian.net/wiki/spaces/CHKDOC/pages/270172389/Modifying+Checklists+using+a+REST+API

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 18, 2018

@Stephen Johnson, no problems :-)

The REST API has effectively been implemented in our latest release Checklist v4.0.0.

Yves

Mike Ricks May 2, 2018

Is there support for creating Checklists programmatically in Jira Cloud?

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 2, 2018

Hey @Mike Ricks,

Sorry, the  cloud doesn't support any API at the moment.

Yves

Bhargavi Gorantla June 1, 2018

@Yves Riel [Okapya] I am trying to update my checklist using REST API and followed the same example as listed in the link(https://okapya.atlassian.net/wiki/spaces/CHKDOC/pages/270172389/Modifying+Checklists+using+a+REST+API).

However, I am getting an error.

"errors": {
"customfield_17600": "Operation value must be a string"

 

Below is the schema of the custom field :

{ "id": "customfield_17600", "name": "Acceptance Criteria (AC):", "custom": true, "orderable": true, "navigable": true, "searchable": true, "clauseNames": [ "Acceptance Criteria (AC):", "cf[17600]" ], "schema": { "type": "any", "custom": "com.okapya.jira.checklist:checklist", "customId": 17600 }

Any thoughts on what am I doing wrong here ?

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 1, 2018

Which version of Checklist are you using? It needs to be v4 and above.

Bhargavi Gorantla June 1, 2018

3.1.13. Is there a workaround for this version ?

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 1, 2018

Sorry no, the REST API was only implemented starting with v4. If you know your way around groovy script, you can do it. This forum has many examples for that.

Bhagi G July 25, 2018

@Yves Riel [Okapya] We upgraded to 4.0.2 and I am still facing the same issue. Any idea what could I be doing wrong ?

Cormac Bonner September 10, 2018

@Yves Riel [Okapya] when will the REST API endpoints be available on Cloud JIRA?

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 10, 2018

Hi Cormac,

It's in our backlog but it's not planned for the short term and I cannot give you a date for it.

Regards,

Balaji October 9, 2018

I'm having the same issue as @Bhargavi Gorantla

How do you find the the checklist plugin version?

Im using JIRA v7.3.8

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
October 9, 2018

Go to the admin section and select the Manage Add-ons page. You'll find there all the installed add-ons and you should find an entry for Checklist along with it's version number.

TAGS
AUG Leaders

Atlassian Community Events