Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Transition via the JIRA REST API with a custom field

Igor Bershov September 29, 2013

Hello everyone,

I want to perform a transition via the JIRA REST API.

For this transition I have a custom field "Time Spent" with a "required" validator.

I try to post:

{
	"timespent": "1h",
	"transition": { "id": "21"}
}

The response sent by the server will be 204, indicated success, but the issue still on the previous stage. I try to post:

{
	"fields": { "timespent": "1h" },
	"transition": { "id": "21"}
}

and even:

{
	"fields": { "worklog": {"timespent": "1h"} },
	"transition": { "id": "21"}
}

The response sent by the server will be 400 Bad Request. The issue still on the previous stage.

What I should post to perform a transition?

3 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
Aleksander Mierzwicki _
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 30, 2013

To update worklog while doing transition you have to use update filed:

{
    "transition": {
        "id": "711"
    }, 
    "update": {
        "worklog": [
            {
                "add": {
                    "timeSpent": "2m"
                }
            }
        ]
    }
}

This worked fine for me when POSTed to /rest/api/2/issue/TST-80/transitions.

0 votes
MichałS
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.
September 29, 2013

I suppose that there is a bug in the REST API, I've noticed that if a transition validator validates false so does the REST API not return the validation error but 204 istead. It shoud actually return the error message of the validator.

Igor Bershov September 29, 2013

Thanks for the answer!

There is a bug https://jira.atlassian.com/browse/JRA-33909 - JIRA REST does not return errors on transitioning an issue.

I want to know what query is correct?

MichałS
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.
September 30, 2013

This is possible if you do not have a transition screen with the timeSpent field that the value is ignored.

The same happens with the comment.

I would suggest you update the issue first with a sepparate REST API call and then push it to another status.

0 votes
RambanamP
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.
September 29, 2013

did you tried something like this

{

	"started": "2013-08-23T16:57:35.985+0200",
    "timeSpent": "3h 20m",
    "timeSpentSeconds": 12000,
    "id": "100028",
	"transition": { "id": "21"}
}

check this

https://docs.atlassian.com/jira/REST/latest/#d2e1573

Igor Bershov September 29, 2013

Thanks for the answer!

I try:

{
    "started": "2013-08-23T16:57:35.985+0200",
    "timeSpent": "3h 20m",
    "timeSpentSeconds": 12000,
    "transition": { "id": "21"}
}

and receive 204, but the issue still on the previous stage.

try:

{
    "fields": 
    {
        "started": "2013-08-23T16:57:35.985+0200",
        "timeSpent": "3h 20m",
        "timeSpentSeconds": 12000
    }
    "transition": { "id": "21"}
}

and receive 400 Bad Request


TAGS
AUG Leaders

Atlassian Community Events