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)