How do I add comments to my Jira ticket through postman?

Hi Iragudo,

I am trying to add comments to my Jira ticket through postman where I am getting error as 404 - Not found. I am using the below code in postman by giving my id and password in authorization:

url = "https://rbcjira.fg.rbc.com:8443/rest/api/3/issue/AALAB-36/comment"


auth = HTTPBasicAuth("email@example.com", "<api_token>")

headers = {
  "Accept": "application/json",
  "Content-Type": "application/json"
}

payload = json.dumps( {
  "body": {
    "content": [
      {
        "content": [
          {
            "text": "Hello",
            "type": "text"
          }
        ],
        "type": "paragraph"
      }
    ],
    "type": "doc",
    "version": 1
  },
  "visibility": {
    "identifier": "Administrators",
    "type": "role",
    "value": "Administrators"
  }
} )

response = requests.request(
   "POST",
   url,
   data=payload,
   headers=headers,
   auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

Am I using the correct API?

@PriyankaGoel,

That URL indicates you are using Jira Server (or Data Center), not Jira Cloud. The REST APIs are different. Specifically, the Jira Server REST API does not have a version 3.

1 Like

The Jira Server API docs have a section with examples for adding comments to issues: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#adding-a-comment–examples

2 Likes