JIRA Cloud-Update Select List Field via Rest API (using Cloud Script Runner)

Chris Lange March 9, 2018

hey there,

I am trying to update the "flagged as impediment" field with Script Runner (Cloud version) in Jira. Unfortunately I am not succeeding at the moment. 

I tried a lot of combinations with brackets to set the value but the issue issn't flagged. I expect that I am missing something obvious and I hope that someone can guide me on the right track :)

def issueKey = 'SAN-3'
def newSummary = 'Updated by a script'

def result = put('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.body([
fields:[
summary: newSummary,
customfield_10050: [{value: "Impediment"}]
]
]).asString()

 

the summary has been updated but the flag has not been set. 

 

Any help is appreciated!

 

 

4 answers

1 accepted

0 votes
Answer accepted
Chris Lange March 27, 2018

finally the Script Runner support could help out. 

 

Working code example (with double [[]]):

def issueKey = 'SAN-3'
def newSummary = 'Updated by a script'

def result = put('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.body([
fields:[
summary: newSummary,
customfield_10050: [[value: "Impediment"]]
]
]).asString()
0 votes
Chris Lange March 22, 2018

any more ideas here?

0 votes
Ryan Yoshioka March 14, 2018

Hey Chris, 

What kind of custom field is  customfield_10050? 

You can look at the exact format of custom field by navigating to: https://yoururl.atlassian.net/rest/api/2/issue/SAN-3

Using a JSON Viewer extension will help immensely when trying to decipher the exact structure. 

Chris Lange March 14, 2018

@Ryan Yoshioka thanks for your reply

 

customfield_10050 is the impediment flag provided by Jira directly (see https://confluence.atlassian.com/jirasoftwarecloud/flagging-an-issue-777002748.html)

 

If an issue is not flagged the field value is null

customfield_10050: null

If the issue SAN-3 got the flag this is the json

customfield_10050: [
{
self: "https://xyz.atlassian.net/rest/api/2/customFieldOption/10003",
value: "Impediment",
id: "10003"
}
]

Calling the field options returns
https://xyz.atlassian.net/rest/api/2/customFieldOption/10003

{
self: "https://xyz.atlassian.net/rest/api/2/customFieldOption/10003",
value: "Impediment"
}


Thanks for your support!

0 votes
Shawn Masters
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2018

Jira Cloud admin here....im not the most well versed API user....but your custom field looks incorrect. 

When im calling on the ones in my project they fit this format:

customFieldId=14125

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events