Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST POST to add attachment gives status 200 OK but no attachment is added to the issue (Cloud)


I'm trying to copy an attachment from a Jira-Software issue to a Jira-ServiceDesk issue (and the other direction as well) by using the ScriptRunner addon (script listener).

Basically I have the "linked issue key" on a text field, so when the attachment is added i get the linked issue by searching the issue with the key retrieved from this field and the attachments added from the event, create a multipartentity and use a /rest/api/3/issue/<issueKey>/attachments POST to upload them to the linked issue.

The issue here is, I get a 200 OK status response, but no attachment is added to the linked issue.

So far I'm testing this on a free instance, to be used on a client instance (I believe Standard plan if I'm not wrong)

The full code is as follows:


if(user.accountId == "557058:d2e5bd5c-dc49-41eb-a6f0-5e01093666c1"){return} //updated by a user different than the scriptrunner addon user
if(!changelog.items*.field.contains("Attachment")){return} //Only if there're attachments added.

import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.entity.mime.HttpMultipartMode
import org.apache.http.entity.mime.content.ByteArrayBody

//ID of integrated projects
def jsmPrId = "10001" //Id of the JSM project
def jswPrId = "10000" //Id of the JSW project
//ID of customfields
def linkCfId = "customfield_10054" //id of the Linked Issue Key custom field

def linkedKey = get("/rest/api/3/issue/${issue.key}?fields=${linkCfId}")
.header('Content-Type', 'application/json')

def attachment
def fileBody
def multipart
for(i in changelog.items){
if(i.field == "Attachment" &&{
attachment = get("/rest/api/3/attachment/${}")
.header('Content-Type', 'application/json')

fileBody = get("${attachment.content.substring(attachment.content.indexOf('/secure'))}").asBinary().body

multipart = MultipartEntityBuilder
new ByteArrayBody(
new byte[fileBody.available()],

.header('Content-Type', "${}")
.header('X-Atlassian-Token', 'no-check')


Any ideas of why this is not working are more than welcome.

Also, testing this on Script Console (for a single attachment) gives a statuscode 200 OK and no attachment is added to the linked issue.


Actually there's another thing about this, if the attachment is bigger than certain contentLength it gives a contentLength too high error (I didn't measure this, basically it did throw the error with a .png file, but not with a test .pdf and a test .txt files)

Thanks in advance, kind regards,


1 answer

Hi @Alvaro Jardón 

It seems that the body is not valid for your API call and that is the reason why you are not to create the attachment. You will need to write your own custom script which gets the details of the attachment from the source issue and then calls the Add attachment API which is documented here to add each attachment to the required issue to copy it over.

Hope this will help you.

Thank you. 

Kind Regards


Hi Kate,

Actually that's what the script I posted does, get the attachment and call the add attachment api...

Also, how is it I get a 200 status code if it's not valid?

Thanks, kind regards,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

247 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you