i am creating jira ticket using Lambda , while adding comment in the existing issue , I am getting error comment body can not be empty, and failed to add comment,
I refer the below comment payload from official doc , even JIRA URL is working fine.
can someone please help me out , I am attaching my function below.
I tried in postman as well, I am getting the same issue.
def add_comment_to_jira(issue_key,messages):
# Jira API endpoint
jira_url = f"https://simijain650.atlassian.net/rest/api/3/issue/{issue_key}/comment"
print("jira_url for comment",jira_url,messages)
# Jira authentication credentials
jira_username = "<username>"
jira_api_token = "<api token of jira>"
# Create payload to add comments to the Jira issue
add_comment_payload = {
"update": {
"comment": [
{
"add": {
"body": "AWS Support Messages:\n" + "\n".join(messages)
}
}
]
}
}
print(add_comment_payload)
#get_issue_key_by_summary(summary)
# Jira API request headers
headers = {
"Content-Type": "application/json",
"Authorization": "Basic " + base64.b64encode(f"{jira_username}:{jira_api_token}".encode()).decode()
}
# Send request to add comments to the Jira issue
response = requests.post(f"{jira_url}", headers=headers,json=add_comment_payload )
print("Status of Post method: ",response.status_code)
print("response",response)
# Check if request was successful
if response.status_code == 200:
print("Comments added to Jira ticket successfully")
else:
print("Failed to add comments to Jira ticket")
print(response.text)
Hi,
In the documentation it is stated that the comment payload should look like this:
{ "body":
{ "content": [
{ "content": [
{ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
"type": "text" } ],
"type": "paragraph" } ],
"type": "doc", "version": 1 },
"visibility": { "identifier": "Administrators", "type": "role", "value": "Administrators" } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.