Bad request create comment with attachment

request:

url - /api/issues/2-1018/comments?fields=id,created,author(name,id),text,attachments(base64Content,name)

Accept - application/json

Content-Type - application/json

Authorization  - Bearer token

body


{

"attachments":[
{
"base64Content":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiwAAAI0CAYAAAA+8nIfAAAABHNCSVQICAgIfAhkiAAAABl",
"name":"image.png"
}
],
"text":"text"
}
response:
{
"author":{
"name":"Andriy",
"id":"1-16",
"$type":"User"
},
"attachments":[],
"created":1628865981930,
"text":"text",
"id":"4-504",
"$type":"IssueComment"
}
 
"attachments":[] is empty. Why???????
1 comment
Comment actions Permalink

Hi!

You need to create a comment first, and then attach a file to it. To get a comment ID, use GET /api/issues/{issueID}/comments and identify the needed comment.

After that, use the resulting endpoint like https://example.myjetbrains.com/youtrack/api/issues/{issueID}/comments/{comment}/attachments?fields=id,created,author(name,id),text,attachments(base64Content,name) to attach the file. The request body is "base64Content" and "name".

0

Please sign in to leave a comment.