REST API - Transition/Change Status Issue Jira Desk Service

Paolo Di Bello August 22, 2019

I want to change the status from closed to open. I think this should be called transition. 

How can I add a transition? I am getting confused about the actual Jira workflow. 

 I only want to be able to open a request if it has been closed using REST. 

GET /rest/api/2/issue/:issueIdOrKey/transitions?expand=transitions.fields

POST /rest/api/2/issue/JC-11/transitions?expand=transitions.fields

BODY:
{ "update": { "comment": [ { "add": { "body": "Comment added when resolving issue" } } ] }, "transition": { "id": "5" } }

To change the transition



Sorry, I have a mental fog right now. 


i've seen this post on a discussion
 to change status from Resolved to Closed it uses transition: id=701. I believe that it's very inflexible because Salesforce has api call limits and I wanted to avoid GET request before POST request. But now I see that it's impossible. I must at first perform GET request and when POST request.

3 answers

1 accepted

2 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 27, 2019

Ciao @Paolo Di Bello ,

Can you kindly provide more details on what you are trying to achieve since I am not sure I have a correct understanding of it?

However, please notice that in your post you are referring to the Jira Core REST API endpoint to transition issues, while there is also a Jira Service Desk REST API endpoint to do the same: 

POST /rest/servicedeskapi/request/{issueIdOrKey}/transition

 

Please find below the links to the Jira Service Desk REST API documentation for Cloud and Server:

 

Then:

  1. In order to make make an issue transition from Closed to Open, you need to have the corresponding transition in your Workflow (a transition that goes from the workflow status Closed to Open) 
  2. You can see all the transition IDs while viewing the workflow as text (in edit mode) 
    Transition-IDs.jpg

 

Kindly provide more details on what you are trying to achieve so that we can further help.

 

Cheers,
Dario

PaoloDiBello August 27, 2019

I think this might be the answer I needed. That's what I wanted to achieve. I'll get back to you tomorrow as I test it and I'll let you know. 


Regards. 

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2019

Hi @PaoloDiBello,

I have just realized I have pasted the wrong link in my previous post that was still pointing to the endpoint to transition Jira Core Cloud issues.

I have now fixed it by adding the correct link (below):

Please review both documentation pages and see which one fits best your needs.

 

Cheers,
Dario

Like Paolo Di Bello likes this
Paolo Di Bello August 29, 2019

Thanks Dario. 

Paolo Di Bello August 29, 2019

@Dario B 

Fine, I can get transitions for a certain workflow but not the one I am using (classic). So the only way I can get transitions is by using this endpoint: 

/rest/api/2/issue/:issueIdOrKey/transitions


I had a project and before switching the workflow and migrating every issue to the classic workflow I could use the endpoint you suggested me but now that I migrated the workflow I cannot see a single transition by using 

/rest/servicedeskapi/request/${issueIdOrKey}/transition
Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2019

Hi @Paolo Di Bello ,

Generally speaking: the Jira Core endpoint will work in any case (Jira Core, Software and Service Desk issues), while the Jira Service Desk endpoint will only work if:

  • The issue is belonging to a valid Jira Service Desk project
  • The issue has a valid request type set

Now, I am not sure if you moved the issues or you just switched workflow or anything else, however, can you check if maybe the issues for which you cannot get transitions using the JSD endpoint are not matching one of the 2 conditions above?

 

Ciao,
Dario

Paolo Di Bello September 5, 2019

Yes, it's matching both conditions. 

I deleted all the issues and made sure the new one had the type as you said. 

I tried making a rest API call to see all the available service desks and the one I am using is in there. 

Paolo Di Bello September 5, 2019

Is there a way to check if the only issue I have has the correct type?

Aren't requests the same as issues? 

Paolo Di Bello September 5, 2019


Here both the Issue types and request types.

Screenshot from 2019-09-05 17-56-54.pngScreenshot from 2019-09-05 17-57-16.png

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 6, 2019

Hi @Paolo Di Bello ,

In short:

  • Issues are how pieces of work are internally represented Jira.

  • Requests are how issues are phrased or represented on the customer portal to customers or end users.
  • More request types can be based on the same issue type. Indeed, as you can see in the second screenshot you attached, each request type is related to an issue type and you have 3 request types associated to the IT Help issue type and 2 associated to the Service Request issue type.

 

For further details on this topic, please review the below documentation:

 

Please let me know if this explain.

 

Cheers,
Dario

Paolo Di Bello September 6, 2019

Ok, I understood the difference and can now tell them apart. 

You told me my issue must respect these parameters in order to be showed
using this REST API:


/rest/servicedeskapi/request/:issueIdOrKey/transition 
  • The issue is belonging to a valid Jira Service Desk project
  • The issue has a valid request typeset

I get the following response with a status of 200. 


{
"size": 0,
"start": 0,
"limit": 50,
"isLastPage": true,
"_links": {
"self": "https://XXX.atlassian.net/rest/servicedeskapi/request/XXX-9/transition",
"base": "https://XXX.atlassian.net",
"context": ""
},
"values": []
}



What I want to be able to do is fix it to make it work with a project. 

I feel like I am messing things up because I am trying to move things here and there changing settings to no avail.

What are the steps I should follow to check that I have correct request types?

Maybe by doing, this should return that and this should that and if it doesn't that I have a problem with that and I should fix it. 


The request type for the only request I have
Screenshot from 2019-09-06 13-02-55.pngScreenshot from 2019-09-06 13-03-22.png

I only kept one request type for each issue type and deleted all the groups.



These are my issue types instead:

Screenshot from 2019-09-06 13-03-46.png



0 votes
Jyothendra October 18, 2023

Hi @Dario B ,

this is transition work flow as we fallow in my JSM.
image (1).png
"I'm using the Service Desk APIs to change the status of an issue or ticket via the Transition REST API. The API token I'm using belongs to an administrator, and they are able to change the status in the web interface. However, when I use the following URL: https://org.atlassian.net/rest/servicedeskapi/request/{issueIdOrKey}/transition, I encounter the following issue."

image (3).png
please help me on this 

0 votes
Paolo Di Bello September 5, 2019

No solution found yet. 

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 6, 2019

Hi @Paolo Di Bello ,

From one of the above comments you have posted, I happen to understand that you migrated a JSD project from Next-Gen to Classic. Is this correct?

If this is correct, then I would suggest to just create a new Classic JSD project and start from scratch. Next-Gen projects are still under development and there are a number of things that don't work the same way as Classic projects yet.

Also, as mentioned in:

Jira Service Desk Cloud introduced next-gen projects in Feb 2019 and developers may experience some differences when calling either the Jira Service Desk Cloud REST API or Jira platform REST API.

App developers and REST API consumers may need to make modifications to support next-gen projects.

 

Please create a new Classic JSD project and test if both endpoints are working in there as well as if you are able to make the issue transition using REST API calls. In case this still won't please provide as many details as possible about what has been done and what failed.

 

Ciao,
Dario

Paolo Di Bello September 6, 2019

This thread is getting a little long. 

What template type should I use? 
How do I tell a project is next-gen or not?

I can't seem to find any info related to the  that when selecting a template

I want a classic workflow. 

In the previous project, I used the Internal service desk template. Once again I could see all the transitions using the rest api but when I switched to classic workflow I couldn't see anything if used the service desk REST API.   

Screenshot from 2019-09-06 14-18-28.png


Open, Close, Reopen and Resolve I think.
These are the only transactions I need. 




Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 6, 2019

Hi @Paolo Di Bello ,

This thread is indeed getting too long so let me try to address one question at the time.

Also, sorry for the confusion caused, you are already using a Classic project. I was mislead while reading that you switched to classic workflow, while 'classic' is actually the name of the workflow scheme you have associated to your Service Desk project (it is now clear from the above screenshot).

Now, in order to answer your questions:

 

How do I know if it is Classic or Next-Gen project:

When creating a project you choose between Classic or Next-Gen as the first thing

Classic-vs-Next-Gen.jpg

However, if you used the "Internal Service Desk" template then you are already using a Classic Service Desk project since there is only one template available for Next-Gen Service Desk so far. For details see: Create edit and delete Next-Gen service desk projects

 

How do I know if a request type is set?

If you create the issue in Jira rather than from the customer portal, you may end up having a valid Jira issue but an invalid Service Desk request, since the request type is missing.

Missing request type:

request-type-missing.jpg

 

Setting request type when missing:

Set-request-type.jpg

 

 

How do I get the transition ids? 

Easiest way is to edit the workflow associated to the project. I did exactly the same you did, I created a JSD project using the internal template and I configured it to use the classic workflow scheme.

Then, go to project setting and edit the workflow (text mode), you will see the transition ids:

edit-classic-workflow.jpg

 

 

------

About the REST API part, I have followed your steps (create internal SD project and change workflow scheme to classic) and I am able reproduce the reported behavior. I need to further look into this since it may be a bug or a change of behavior (or we are missing something).  

In the meanwhile, you can use the Jira Core REST API endpoint to get the transition ids, since that one is working fine and it applies to every kind of Jira issue, not only the Service Desk requests:

https://xxxx.atlassian.net/rest/api/2/issue/ISSUE-KEY/transitions

 

I hope this clarifies.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer