Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Update a version with PUT API

Edited

Hi community! I am trying to update some version fields but it gives me the following error about this code

def result = put("/rest/api/3/version/${releaseID}")
.header('Content-Type', 'application/json')
.body([
fields: [
description: Descripcion,
name: Nombre,
startDate: FechaInicio,
releaseDate: FechaRelease

]
])
.asString()

2023-09-22 12:41:19.243 INFO - PUT /rest/api/3/version/10675 asString Request Duration: 391ms
2023-09-22 12:41:19.244 WARN - PUT request to /rest/api/3/version/10675 returned an error code: status: 400 - Bad Request
body: {"errorMessages":["Invalid request payload. Refer to the REST API documentation and try again."]}
2023-09-22 12:41:19.244 INFO - Serializing object into 'interface java.util.Map'

 

2 answers

1 accepted

0 votes
Answer accepted
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 22, 2023

Hi @Gustavo Barrios 

 

I could be an issue with the type of variable you have in description, name, startDate or releaseDate.

 

Regards

Hi @Florian Bonniec These are the variables and how I am capturing them:


Map Issue = get("/rest/api/3/issue/${issue.key}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body

String Descripcion = issue.fields.description
String Nombre = Issue?.fields["summary"]
String FechaRelease = Issue?.fields["customfield_10090"]
String FechaInicio = Issue?.fields["customfield_10171"]
String releaseID = issue.fields["versions"]?.find()["id"]

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 25, 2023

Have validate that each variable has the expected value in the expected format using logging ?

 

You could try to log the body and send it using postman for instance to validate the payload is right.

 

Reagrds

I was able to solve it by leaving the code like this, removing fields:

def result = put("/rest/api/3/version/${releaseID}")
.header('Content-Type', 'application/json')
.body([
description: Descripcion,
name: Nombre,
startDate: FechaInicio,
releaseDate: FechaRelease

])
.asString()

 

Thank you all for the help.

0 votes
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 22, 2023

Hi @Gustavo Barrios 

Well, url and method seems fine.

Update version

Could you please double check request body (parameters) you send? Doc says ID is required.

Hi @Tansu Akdeniz I see that the ID is not required in the request body, is required in 

Path parameters

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events