Domanda

I had a hunt for this all over the place and found a few resources that had a lack of decent examples such as here, here and here.

The most helpful was this one. which gave the following:

curl -D- -u myname:mypassword -X PUT -d "{\"fields\":{\"summary\":\"My title thru Curl\"}}" -H "Content-Type: application/json" http://localhost:portnum/jira/rest/api/2/issue/Issue-4

How can I add a comment?

È stato utile?

Soluzione 2

This can be achieved by doing the following:

curl -D- -u uname:pass -X PUT -d "{\"update\": {\"comment\": [{\"add\": {\"body\": \"Comment added when resolving issue\"}}]}}" -H "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/issue/KEY-12345

I've added a gist here which gives a couple of use cases

Altri suggerimenti

I found another option that is just adding a new comment without modifying the issue itself (it might be good when the user doesn't have rights to edit but only to comment).

curl -D- -u uname:pass -X PUT -d "{\"body\": \"Comment added when resolving issue\"}" -H "Content-Type: application/json" http://jira-server:8080/jira/rest/api/2/issue/KEY-12345/comment

You should just receive a response with a status of "201" with the full json representation of the added comment.

It's well documented now in https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-add-comment

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top