New REST API: adding attachments doesn't appear to work

Answered

We need to be able to add attachments to issues through the REST API and I can't get this to work in the new API.

I've tried including an attachment when creating a new issue and when updating an issue and in both cases I don't get an error, but the attachment isn't added.

On the update, the body is set to:

{
"attachments": [
{
"name": "mytest.txt",
"base64Content": "VGhpcyBpcyBzb21lIHRlc3QgY29udGVudA=="
}
]
}

I tried this with the $type field set to jetbrains.charisma.persistent.issue.IssueAttachment, but that didn't make any difference.

I see that comments can be maintained since there is an endpoint for them, so maybe attachments need something similar.

 

5 comments
Comment actions Permalink

Hello,

Which content type did you use in your REST request?

I'd recommend referring to how YouTrack issues these requests itself since this is exactly the request you need.

0
Comment actions Permalink

The body is marked as being JSON. I'm using Postman and a permanent JWT token to access the API. I was able to create a new issue, just not able to add an attachment.

I did try to look at the YouTrack code by getting the source from the browser, but couldn't find the calls for attachments.

John

0
Comment actions Permalink

John,

I am very sorry for the delay. Please use "Content-Type: multipart/form-data" to add an attachment.

Please let me know if it helps. 

0
Comment actions Permalink

I did get instructions on how to use the attachments end point and was able to get everything to work.

0
Comment actions Permalink

Thank you for the update, have a nice day!

0

Please sign in to leave a comment.