add dynamic comments in jira

anil kumar March 18, 2021

hi folks,

 

i m getting 400 response while adding comment.

basically i want to add dictionary key,values as a comment.

Can you pls help me on this ?

 

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

comment_dict={}
comment_dict['project_name']=project_name
comment_dict['version']=release_label
comment_dict['envirnoment_name']=envirnoment_name
data = '{"body": comment_dict}'
jira_comment_url='https://jira.abc.net/rest/api/latest/issue/'+str(jira_tkt.upper())+'/comment'
print("jira comment url is",jira_comment_url)
response_8 = requests.post(jira_comment_url, headers=headers, data=data, auth=(username,password))
print(response_8)

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 18, 2021

Hi @anil kumar I'm not sure, what programming language you use. But it seems to mee that you create map comment_dict and you send it as a body. But you need to add body as String as described here: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.13/#api/2/issue-addComment. So instead of creating a map, you need to join some Strings together...

Suggest an answer

Log in or Sign up to answer