API Comment Posting in Jira
How do I programmatically insert comments into Jira Data Center issues using the API? See my revised code below.
import axios from 'axios';
const apiClient = axios.create({
baseURL: 'https://jira-dc-demo.company.local/rest/api/2',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessKey}`
}
});
function postComment(issueKey, text) {
return apiClient.post(`/issue/${issueKey}/comment`, { body: text });
}
// Example usage
postComment('PROJ-456', 'This comment was added via a new API call');