Reputation: 828
I have created an MVC application that sends an email to JIRA which in turn creates the issue successfully. But in the application I would like to update the issue by being able to add a comment to an existing issue. Because at this moment if you send another email it will just create another issue and this is not feasible to add comments to the current issue.
Is there a way in which you can set up an email handler for JIRA so that when it receives the email it can recognize the Issue (by using the Issue Key) and then add a comment.
I am pretty sure that you can add a comment by just making it the body of the text and setting up JIRA to interpret this as a comment and not a description. But if you make the Issue Key the subject of the email is there a way to set up JIRA so that it updates that issue?
Upvotes: 0
Views: 632
Reputation: 828
I found out that I can add a comment to an existing issue via email by doing the following.
Firstly in the MVC application I will identify the issue by getting it from its ID, then I will retrieve the issue Key from this.
Dim Issue As New IssueResultTable
Issue.key
Then I will make that the subject of my email in this format:
Subject: [JIRA} (KEY-00000)
If that key exists in the JIRA system it will automatically search for it and add the body as a comment to the existing issue.
If an email message contains an existing issue key in its subject line and that issue key in your JIRA system, the email handler will add the email message content as a comment on the issue.
You then can also check the strip quotes option to edit out the previous emails content from the comment.
Upvotes: 0
Reputation: 22074
Jira has a REST API - so why you don't send REST request for adding a comment ?
POST /rest/api/2/issue/{issueIdOrKey}/comment?expand
Adds a new comment to an issue.
request query parameters
parameter value description
expand string optional flags: renderedBody (provides body rendered in HTML)
acceptable request representations: application/json
Example { "body": "Lorem ipsum dolor sit amet....", "visibility": { "type": "role", "value": "Administrators" } }
available response representations:
201 Example { "self": "http://www.example.com/jira/rest/api/2/issue/10010/comment/10000", "id": "10000", "author": { "self": "http://www.example.com/jira/rest/api/2/user?username=fred", "name": "fred", "displayName": "Fred F. User", "active": false }, "body": "Lorem ipsum dolor sit amet...", "updateAuthor": { "self": "http://www.example.com/jira/rest/api/2/user?username=fred", "name": "fred", "displayName": "Fred F. User", "active": false }, "created": "2015-06-23T08:28:32.838+0000", "updated": "2015-06-23T08:28:32.838+0000", "visibility": { "type": "role", "value": "Administrators" } } Returned if add was successful 400 Returned if the input is invalid (e.g. missing required fields, invalid values, and so forth).
Reference: https://docs.atlassian.com/jira/REST/latest/
Upvotes: 1