I’m currently working with Jira Data Center and need to programmatically insert comments on issues using the API. While I have the right permissions and can initiate authenticated requests, I’m uncertain about the right endpoint and the format of the data payload for adding comments.
Here’s my existing setup:
API Method Used: POST Request
Using Axios:
this.jiraAPI = axios.create({
baseURL: 'https://jira-dc-qa.YOUR-COMPANY-NAME.com/rest/api/2',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${yourToken}`
}
});
return this.jiraAPI.request({
method: 'POST',
url: `/issue/${issueKey}/comments`,
data: {
message: "my comment"
}
});
Could anyone share a comprehensive example of how to correctly structure the request for adding a comment? Also, are there specific headers or authentication elements that I need to include?
Correction Made: Ensured the Axios settings and request parameters were properly structured, including the essential data field for the comment message.
Desired Result: My goal is to ensure that after making these changes, the API request would successfully add a comment to the designated Jira issue, provided that the endpoint, authentication, and permissions are aptly configured.