Hello
I am unable to create a copy of existing comment to another issue (using rest api V3 and groovy on Jira Cloud) if it contains image ("type": "mediaSingle"). For example, I can grab a comment with this code:
def commentToAdd = get("/rest/api/3/issue/${issueKey}/comment/15513")
.header('Content-Type', 'application/json')
.asObject(Map)
.body
bodyToAdd = commentToAdd.bodyThen I try to create a new comment:
def commentResp = post("/rest/api/3/issue/${targetIssueKey}/comment")
.header('Content-Type', 'application/json')
.body("body": bodyToAdd)
.asObject(Map)
assert commentResp.status == 201 If comment contains picture, code will return error:
status: 400 - Bad Request body: {errorMessages=[], errors={comment=Comment body is not valid!}}
If comment does not contain picture (if it has only paragraphs), comment will be created.
I tried to remove picture from content array and when I do so, comment will be created. To test this, I iterated through content array and and ignored all types other than paragraph:
def newContent =[]
for (contentLine in commentToAdd.body.content){
if(contentLine.type == 'paragraph')
newContent.add(contentLine)
}
bodyToAdd = [version: 1, type: "doc", content: newContent]
When this code is executed before calling previous code with post, the comment will be created, and the picture will obviously not be there, because it was skipped.
Does anyone have a suggestion what may be wrong? Thanks