I want to set an id for the fixVersion by a script.
It is able to set by REST API using Python' s requests method as following,
#------
url = "https://xxxxxxx.atlassian.net/rest/api/3/issue/TTES3-6"
auth = HTTPBasicAuth("xxxx","xxxxxx")
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
payload = json.dumps( {
"fields": {
"fixVersions": [{"id": "10091"} ],
}})
response = requests.request(
"PUT",
url,
data=payload,
headers=headers,
auth=auth
)
print (response.status_code)
But it is unable to set using ScriptRunner's Script Console,
#------
def result = put("/rest/api/3/issue/TTES3-6")
.header('Content-Type', 'application/json')
.body([
fields:[ fixVersions:[{id: '10091'}]
]
])
.asObject(Map)
return result.status
#-----
Return code is 204, but the fixVersion field becomes blank.
(Another field like summary or custom field seems to be able to set value using same method....)
What's wrong?
@馬場泰年 -
You should take a look at ScriptRunner script example using Groovy to set issue values - https://docs.adaptavist.com/sr4jc/latest/features/script-console/script-examples
You may also want to contact Adaptavist for support directly.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Infrastructure Applications Team
Viasat Inc.
@Joseph Chung Yin
Dear Mr. Yin.
Thank you for your advice.
I didn't understand how to convert JSON to Map format used on Groovy.
//re-wrote script
def result = put("/rest/api/3/issue/TTES3-6")
.header('Content-Type', 'application/json')
.body([
fields:[
fixVersions:[ [id: '10091'] as Map ]
]
])
.asObject(Map)
return result.status
//It's OK. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@馬場泰年 -
Why do you want to convert it to a map? I don't believe it is necessary. Take a looking at the page that I mention to you in the previous posting and look at the script example "Update an Issue".
Best, Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.