0

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.

2
  • You don't have to put the word Title in the title of your post. It's clear from the site's placement and formatting of that text that it is the title. Adding that to the title itself is just noise. Commented Sep 12, 2024 at 23:42
  • And when you ran this code, what was the ACTUAL outcome? What error message, if any, did the API endpoint respond with? What change, if any, happened to the Issue in Jira? Commented Sep 14, 2024 at 1:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.