Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

I can update the attachment whit groovy CLOUD

I have this code to update the new SubTask in  transition, but I have problems to put the news attachments:

Captura.PNGCaptura2.PNG

 

2 answers

2 accepted

I found this code, and tested it. It works fine, you could addapt it for your purpose:

import org.apache.http.entity.ContentType

def getIssue = 'SD-3'
def result = get('/rest/api/2/issue/' + getIssue)
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
logger.info('sucess')
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}

result.body.fields.attachment.collect {
attachment ->
def url = attachment.content as String
url = url.substring(url.indexOf("/secure"))
def fileBody = Unirest.get(url).asBinary().body
def postIssue = 'SD-4'
def postResult = Unirest.post("/rest/api/2/issue/" + postIssue + "/attachments")
.header("X-Atlassian-Token", "no-check")
.field("file", fileBody, ContentType.create(attachment['mimeType'] as String), attachment['filename'] as String)
.asObject(List)
assert postResult.status >=200 && postResult.status < 300
}

Regards 

Muchas gracias Alejandro;

Es justo lo que necesitaba:

 

It was wonderful, cause is Exactly that I need.

Thank's

For all the people that need a similar Script or same Script, In CLOUD is very important (in this case) to put the import class.

import org.apache.http.entity.ContentType

Because if not put, it will be an error

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

292 views 5 14
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