I'm working with Jira Data Center and need to add comments to issues programmatically using the API. I have the necessary permissions and am able to make authenticated requests, but I'm unsure about the correct endpoint and payload format for adding comments.
Here's what I have so far:
API method used: POST request Using Axios:
this.api = axios.create({
baseURL: 'https://jira-dc-qa.MY-COMPANY-NAME.com/rest/api/2',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
return this.api.request({
method: 'POST',
url: `/issue/${issue}/comment`,
data: {
body: "example comment"
}
});
Could someone provide a detailed example of how to properly format the request to add a comment to an issue? Additionally, are there any specific headers or authentication details required?
Code Correction: Ensured the Axios configuration and request options were correctly formatted and included the required data field with the comment body.
Expected Outcome: I expected that with these adjustments, the API call would correctly add a comment to the specified Jira issue, assuming the endpoint, authentication, and permissions are correctly set up.