I could be missing something but it looks like if you issue a POST to transition an issue from one status to another, if you want to have it update any of the fields, including a comment, you have to have a screen associated with the transition. And that screen must have whatever fields you want to update/modify. Is there any way around this? Thanks!
Community moderators have prevented the ability to post new answers.
That is correct - REST respects your settings in the UI. If you can't do something in the UI (like add a comment during a transition), then you can't do it in REST either.
Thanks, Nic. I'm surprised you don't get an error code returned or something to denote that the comment (or any other field) did not get written.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Chris Kast I've been surprised too and working to determine a way to figure this out in API. Atlassian Support said that there is a concept of "hasScreen" property in the workflow transition, but this isn't available in the API.
The safest assumption I can make at this point is first gathering the fields property (literally "fields") as such: https://prodjira/rest/api/2/issue/CNG-950/transitions?expand=transitions.fields ...If there is a screen associated, the fields that are available to update (NOT including the actual "comments" -- literally everything but that) will show. However the important part here is also that if there are no fields able to be updated, there will be no screen, and this will return with no properties below for that particular transition. So, you can check for that being 0/null/empty and know you can't comment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The screen of transition is not mandatory neither the comment when you transition an JIRA issue. It is configured in your work flow scheme (https://confluence.atlassian.com/display/JIRA/Working+in+text+mode#Workingintextmode-transitionviewUsingascreenwithatransition) which you can adjust according to your needs.
Actually if you need provide comments or fill other required fields in REST call to transition an JIRA issue, you can put extra information in it. Here is the REST API for JIRA transistion: https://docs.atlassian.com/jira/REST/latest/#d2e4630.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmmm. I did a quick test and if I use the following payload and the transition does not have a screen associated with it, the transition happens but no comment is created. If I add a screen that has the "comment" field on it, the comment gets written as expected. In both cases, I get a return code of 204. data = { "update": { "comment": [ { "add": { "body": "This should totally work." } } ] }, "transition": { "id": "781" }, }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"The fields that can be set on transtion, in either the fields parameter or the update parameter can be determined using the /rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields resource. If a field is not configured to appear on the transition screen, then it will not be in the transition metadata, and a field validation error will occur if it is submitted." If I read it correctly, that means you can not put extra fields in the POST DATA where it is not required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.