curljirajira-rest-apijira-rest-java-api

Update JIRA ticket status using REST API


I am able to create a ticket in JIRA using CURL command and having a json data handy.

curl -D- -u : -X POST --data @< filename> -H "Content-Type: application/json" http://< hostname>:< port>/rest/api/2/issue/

I was now trying to update the status of the ticket generated but was getting the following error. {"errorMessages":[],"errors":{"status":"Field 'status' cannot be set. It is not on the appropriate screen, or unknown."}}

Curl command:

curl -D- -u < user>:< pwd> -X PUT --data @data_update.txt -H "Content-Type: application/json" http://< hostname>:8100/rest/api/2/issue/MTF-3


Solution

  • Status is not a field in Jira and thus changing the same on fly is not possible. JIRA API doesn’t have provision for that.

    We have to follow the transitions and change accordingly.

    First, execute ‘http://localhost:8100/rest/api/latest/issue/MTF -2/transitions?expand=transitions.fields and know the id’s for transitions.

    For Eg: transition id for “Stop Progress” is 31, for “Done” is 41.

    Once that is known, use the following link by adding values pertaining to your environment:

    curl -D- -u <USER>:<PASS> -X POST --data '{"transition":{"id":"<TRANSITION_ID>"}}' -H "Content-Type: application/json" <JIRA_URL>:<JIRA_PORT>/rest/api/latest/issue/<JIRA_ISSUE>/transitions?expand=transitions.fields
    

    Reference: Check Paul grants answer - https://answers.atlassian.com/questions/107630/jira-how-to-change-issue-status-via-rest