API Adding a comment with a transition message

Marcell July 8, 2013

When I use the API to apply a transition I don't seem to be able to attach a comment to the issue altough the API documentation clearly says I should be (https://docs.atlassian.com/jira/REST/latest/#idp2074672)

Here is the JSON I'm trying to send via POST:

{
    "update": {
        "comment": [
            {
                "add": {
                    "body": "Some comment"
                }
            }
        ]
    },
    "fields": {
        
    },
    "transition": {
        "id": "1"
    }
}

The issue is being moved without problems and I don't see any errors in the response either, it feels like the method is just broken. Any suggestions? Thanks!

10 answers

1 accepted

0 votes
Answer accepted
Marcell July 25, 2013

It seems the problem resolved itself although I haven't touched the code in a while. It was possibly a temporary issue with Atlassian's webservice. Thanks for the suggestions anyways.

zeuyanik April 12, 2017

Actually, the problem that you mention is still valid, I couldn't add comment while doing the transition.

1 vote
Szilágyi Zoltán October 24, 2020

The issue is still present. You can make the transition with a comment inside the request, but only the transition will be processed, the comment not.

1 vote
Tanu Ranjan Bharadwaj April 8, 2019

If you are trying to add a comment on any transition and facing problem in showing the comment because Comment field is not present on that transition so as a Solution for this, JIRA has a provision to add a screen on that transition with a Comment field on that screen. Then you will be able to see the comment in the comment section of that issue.

It will work fine then.

Antolene Capili February 9, 2020

Except that there's no Comment field that you can add to a screen.

Proof: https://confluence.atlassian.com/jirakb/how-to-add-a-comment-during-a-transition-779160682.html

manas_shukla September 24, 2020

You do not have to make a custom screen for every transition. You can select the Default Screen and that should get all the fields, including Comments field. 

0 votes
Vladimir Ryabtsev December 3, 2018

Same with me. The issue transits, but there is no comment. I do have Comment field on the screen of this transition ID.

+ 1 more thing: API now seems to not accept basic text content (like {"body": "Text"}), but it works with more complicated "document" format (like in this example: https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-issue-issueIdOrKey-comment-id-put). By "works" I mean "does not fail and returns HTTP 204". Still there is no comment appear.

Additionally, the methods works separately, if I call /issue/key/comment and issue/key/transitions it works as expected.

0 votes
Evan Wolf August 8, 2018

I would love a resolution to this issue!

0 votes
Will Prater May 18, 2018

Im experiencing this issues as well, is there a fix?

0 votes
Marcell July 8, 2013

I still believe it has nothing to do with client, but anyways here is my code:

http = Net::HTTP.new API_HOST, 443
http.use_ssl = true
req = Net::HTTP::Post.new "/rest/api/2/issue/JIRA-123/transitions", initheader = {'Content-Type' =>'application/json'}
req.basic_auth USERNAME, PASSWORD
# Load in request body template file
renderer = ERB.new File.new("transition.erb").read, nil, "%"
# Substitute variables with values and set result as the body
req.body = renderer.result
http.start do |http|
  response = http.request req
end

Also note that I'm using ondemand so it might has a slightly different configuration.

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.
July 8, 2013

the following client code i have used test REST

package com.rest.client;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;

public class RESTclient {

	public static void main(String[] args) {
		try {
			Client client = Client.create();			
			client.addFilter(new HTTPBasicAuthFilter("admin", "admin"));
			WebResource webResource = client.resource("http://LOCALHOST:8080/rest/api/2/issue/JIRA-100/transitions");		
		String input="{ \"update\": {\"comment\": [ { \"add\": {\"body\": \"Testing.\"} }]},\"fields\": {}, \"transition\": { \"id\": \"21\" }} ";	
			ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input);	
			String output = response.getEntity(String.class);
			System.out.println("Output from Server .... \n");
			System.out.println(output);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

0 votes
Marcell July 8, 2013

I got the same result using a browser-based REST client like postman and writing an API service myself. I doubt it has anything to do with client code as the issue is being transitioned just fine. I also double checked the API user permissions and it does have right to insert comments. Is it possible that I need to enable something in the settings to make it work?

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.
July 8, 2013

i can able to add comment with your JSON which is

{ "update": { "comment": [ { "add": {"body": "Bug has been fixed."} }]},"fields": {}, "transition": { "id": "21" }}

how your trying to update? if you are using any client can you post your client code?

Suggest an answer

Log in or Sign up to answer