Hi community,
I am using Scriptrunner Cloud to attempt to retrieve the members of a Jira group (group1), and write those users to a multi user picker custom field.
---
def gusers = get("/rest/api/3/group/member?groupname=group1")
.header("Content-Type", "application/json")
.asObject(Map)
def accountdetails = gusers.body.values as List<Map>
def accountids = accountdetails.accountId
def modaccountids = accountids.collect{'["id":' + '"' + it + '"]'}
print(modaccountids)
//api call
put("/rest/api/3/issue/ABC-123")
.header("Content-Type", "application/json")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.body([
"fields": [
"customfield_xxxxx": [
modaccountids
]
]
])
.asString()
Any help would be greatly appreciated!
Hi community,
After a few more cycles, I was able to resolve this issue. In my original post, I thought my issue was related to the way formatting the list of account IDs, and that did turn out to indeed be the issue. Here is how I resolved it...
Original: def modaccountids = accountids.collect{'["id":' + '"' + it + '"]'}
Updated: def idList = accountids.collect { item -> ["id": item] }
Hopefully this can help the community at some point in the future. Cheers!
Hi @Cooper Latham ,
With mine issue, it turned out
body: {"errorMessages":[],"errors":{"customfield_10246":"data was not an array"}}
Would you please mind taking a look at my script? I still have not figured error cause. I am very appreciate with your help.
Here below is the script using in Post-function:
def issueKey = issue.key
def result = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
"customfield_10246": [
"id": "61812ae5062f4c006918316e"
]
]
])
.asString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My mistake, I just need to put accountId object between the "[ ]".
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.