How can we update transition of issue while creating it by rest api in single request

Saurabh Bhandari January 7, 2021

I am creating bulk issues using issue/bulk and I need to set the specific workflow of the created issues 

How can i change the transition of issue while creating it

2 answers

1 vote
Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

Hi @Saurabh Bhandari ,

You cannot. It will first need to be saved in the initial state and then transitioned in a different call to the correct State.

You will need the id of the issue that was created to transition it so it has to be 2 calls.

A workaround could be to add a custom field with a flag or something and then set an automation in JIRA to auto transition the issues to this state based on that "flag"

Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

Instead of a flag you could also set the State that you want it to go to in a custom field and then based on that transition to the correct state (after creation of course)

Saurabh Bhandari January 7, 2021

Thanks for the reply It was helpful.

One more question :

In which case I will get the value of status field under transition node on create issue response

{
    "id": "10000",
    "key": "ED-24",
    "self": "https://your-domain.atlassian.net/rest/api/3/issue/10000",
    "transition": {
        "status": 200
,
        "errorCollection": {
            "errorMessages": [],
            "errors": {}
        }
    }
}

 What does it indicate and what fields I need to add on request

Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

@Saurabh Bhandari ,

Details regarding the transition itself you can find here: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-post

The id of the transition (cause you perform a transition from status A to status B) you will need to find in your instance (this is specific to your environment)

From what I can see both the transition and the creation use the same endpoint so the response might only contains something in the transition when it was done.

Saurabh Bhandari January 7, 2021

Thanks again 

I am bit confuse

As while creating issues using issue/bulk mentioned in https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulk-post

doc says that in response I will get the response as

{
    "id": "10000",
    "key": "ED-24",
    "self": "https://your-domain.atlassian.net/rest/api/3/issue/10000",
    "transition": {
        "status": 200
,
        "errorCollection": {
            "errorMessages": [],
            "errors": {}
        }
    }
}

 but when I am trying to create an issue I am getting only 

{
    "id": "10000",
    "key": "ED-24",
    "self": "https://your-domain.atlassian.net/rest/api/3/issue/10000"
}

So in what case or by adding which fields in request I can the value of transition node

Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

So let's take a step back here.

What endpoint are you currently calling? Could you post your payload and the endpoint you are calling? is this the /rest/api/3/issue/bulk or /rest/api/3/issue ?

The "longer" reply is most likely when you already include a transition in the creation while the shorter one is only when you just do the creation.

As the documentation states you can add the transition in the creation it might be possible to immediately transition to the correct one too. Something I might have missed myself in the past.

 

Saurabh Bhandari January 7, 2021

@Dirk Ronsmans 

I am using rest/api/3/issue/bulk

This is my payload : 

{
    "issueUpdates": [
        {            "transition": {
                "id": "123",
                "looped": false
            },
            "fields": {
                "summary": "Test Epic Name By Saurabh",
                "issuetype": {
                    "name": "Story"
                },
                "project": {
                    "key": "TP"
                },
                "priority": {
                    "id": "1"
                }
            }
        }
    ]
}

 

Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

i've been doing some tests myself and can't seem to get it working with bulk.

When I do a /rest/api/3/issue call with a transition I can immediately transition the issue to the correct status and I get the correct response.

{
"fields": {
"summary": "fsdfsdfsdfsdf",
"issuetype": {
"name": "Incident"
},
"project": {
"key": "ISD"
}
},
"transition": {
"id": "131"
}
}

 

When call the /issue/bulk endpoint it just creates and doesn't transition.

I wonder if this is even implemented on the bulk endpoint. For me atleast I can't seem to find a way to auto transition with a bulk create..

@Ganesh Babu any ideas?

Ganesh Babu
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

@Dirk Ronsmans No, I am not sure whether perform the transition is implemented for the bulk endpoint. On the bulk operation the endpoint is slight different to one with single operation. And i see only the bulk create endpoint. 

0 votes
Ganesh Babu
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

Hello @Saurabh Bhandari ,

You can use the CSV method to create the bulk issues and while importing the issues you can change the status of the issues but this wouldn't be called as transitioning of the issue, like we can map the status of the issue through the UI.

But I am not sure when you say - need to set the specific workflow?

But for performing the transition using API, it would require the issue id, to perform the operation, where in we can get the issue id, post the creation of the issue.

So we might have to create the issue, retrieve the issue id for those and then perform the transition.

Thanks and Regards,

Ganesh Babu J

Ganesh Babu
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2021

Hello @Saurabh Bhandari 

To get the value of the status, you need to execute the Get transitions api call which is going to provide you the value for the status field. Or It is using the workflow statuses api,

The transition is going to be performed based on the transition id.

Important is that the endpoints for transition & creation are different

https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#status-codes

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events