I am unable to add custom properties to the comments while creating the comment using the following JIRA rest api endpoint,
POST /rest/api/2/issue/{issueKey}/comment
I am sending the following data to the endpoint,
{
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"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"
}
]
}
]
},
"properties":[
{"key":"key1",
"value":"Value1"}]
}
If I remove the âpropertiesâ key from the request data the comment creation succeeds else it throws the following error with status code 500,
{
âerrorMessagesâ: [
âInternal server errorâ
],
âerrorsâ: {}
}
Am I doing something wrong? How do I add custom properties while creating comment in Jira?
2024-04-09 13:47:50.801 INFO - Serializing object into âinterface java.util.Mapâ
2024-04-09 13:47:50.801 INFO - POST /rest/api/2/issue/431734/comment asObject Request Duration: 213ms
2024-04-09 13:47:50.802 WARN - POST request to /rest/api/2/issue/431734/comment returned an error code: status: 400 - Bad Request
body: {errorMessages=[Invalid request payload. Refer to the REST API documentation and try again.]}
2024-04-09 13:47:50.802 INFO - Response: status: 400 - Bad Request
body: {errorMessages=[Invalid request payload. Refer to the REST API documentation and try again.]}
2024-04-09 13:47:50.811 ERROR - Assertion failed:
assert commentResp.status == 201
| | |
| 400 false
status: 400 - Bad Request
body: {errorMessages=[Invalid request payload. Refer to the REST API documentation and try again.]}
@HugoUnknown rather than replying to a post from 4 years ago, Iâd recommend creating a new post (you can always write something like âI saw this similar post and tried the suggestionâ) as thereâs no guarantee the same person who originally answered will be available to reply, and itâs possible that things may have changed in that time.
@HugoUnknown if youâre still stuck, the answer is actually the same as it was for Gaurav - hereâs another example - hopefully itâs a little clearer:
var bodyData = `{
"body":"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.",
"properties":[
{
"key": "myKey",
"value": {"dataKey": "Data"}
}
],
"author":null
}`;
So, for the properties, you need to have defined an array of {"key": [String], "value": [JSON Object]} - in your example you have defined an array with {"value": [String]} which isnât valid