Missed Team ’24? Catch up on announcements here.

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

JIRA REST API add issue and comment problem

Nad Af December 27, 2012

When I try to add a new issue and a comment I get the following error:

{"errorMessages":[],"errors":{"comment":"Field 'comment' cannot be set. It is not on the appropriate screen, or unknown.

Here is what I send as input. I have JIRA 5.1

{
    "fields": {
        "project": {
            "key": "MYPROJECT2"
        },
        "summary": "Title",
        "description": "Issue body",
        "issuetype": {
            "name": "Incident"
        },
        "reporter": {
            "name": "username"
        }
   
},
    "update": {
        "comment": [{
            "add": {
                "body": "A comment "
            }}]
    }
}

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2012

You don't add comments during issue creation, that's why it won't work.

Generally, anything you would want as a "comment" on an issue, if you know it at the time of creating the issue, you'd put it in the description (and/or spread it through other fields as appropriate). Comments are for later in the life-cycle - they're for more information later.

Nad Af December 27, 2012

I am confused. The documentation says you can do that:

Comments may be added either via the rest/api/2/issue/{issuekey}/comment resource or as part of editing or creating an issue.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2012

I'm not sure the docs are correct on that one.

Actually, it might be technically correct, in that posting a comment is supported in the code, but comments don't appear on create screens, so the response "it is not on the appropriate screen" is also correct (and that is breaking it for you).

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2012

I'm not sure that it is a bug - I mean you can't add a comment during issue creation in the UI, so I wouldn't expect REST to allow it either - that would be inconsistent.

A flaw, perhaps, although whether it's in the docs or the design, I'm not sure.

I would question the human side - does it really make sense to be adding a comment while you're creating an issue? Surely you should put all your initial descriptive information in the description? A comment divides the information up, and isn't really an update giving more.

Nad Af December 27, 2012

I think it's a bug.

Nad Af December 27, 2012

I see. However, It's a requirement in my company. We need to put some info which will change over time, if we put the info in the body, it will remain there and we can't delete it because we need to keep a history, so the only way is to add a comment.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2012

Um, that's not right. Or, I've completely misunderstood what you've just said (which is more likely - I'm good at misreading things)

If you really need to keep some information, the worst possible place is the comments because you can edit or delete comments without any log of the original information.

However, if you put information into the body of the issue (i.e. description, or any other text field), then if it's edited in any way, including being blanked out completely (deleted), then the information is still retained in the history.

If you really do need this sort of permanent initial comment separated out from the description, then I'd simply create a custom text field to hold it. Call it something like "initial comment" or "creation comment".

Nad Af December 27, 2012

The comments are stored in a DB before they're sent to JIRA, so no worries if the comments are deleted.

How do I create a custom text field ?

Thanks.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2012

Mmm, sounds like pointless duplication there ;-)

Custom text field - see the documentation on custom fields - it's pretty standard in Jira that you add them to capture and track information that is not covered by the system fields.

Anyway, another option might be to create on one call and create the comment with a second call.

Like amit_lodhi likes this
1 vote
Renjith Pillai
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.
December 27, 2012

Why don't you just create the issue and then add the comment (two REST calls)?

And regarding the docs, I guess you are referring to https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Add+Comment. Will get that updated.

Renjith Pillai
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.
December 27, 2012

Doc updated.

0 votes
zahid khan April 23, 2019

Thanks for sharing this blog. The content is beneficial and useful. Very informative post.

write for

0 votes
Deleted user July 30, 2018

Two calls seem to be required, but it would sure save people a lot of wasted time if the docs were simply checked and updated.  See:

https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue

This shows adding a worklog entry during issue creation, which also doesn't work.  

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events