Hi guys,
I'm currently trying to set a component to an issue via ScriptRunner and am (probably) failing because of the correct syntax.
Can someone help me? Thanks in advance!
Update Code Snipped:
// Update the issue
def resultIssueUpdate = put("/rest/api/2/issue/${issue.key}")
//.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
.body([
fields:[
components:[id: "10009"]
]
])
.asString()
Result:
PUT request to /rest/api/2/issue/FIBU-5098 returned an error code: status: 400 - Bad Request {"errorMessages":[],"errors":{"components":"The list contains an invalid value"}}
Best regards
Benjamin
Hi Benjamin,
I can confirm that to set a component, you can use the example located here.
Using this, you will see that the components field needs to be an array where each element is an array which has the name and value of the component.
This example can be run on the script console to see how it works and then moved into other scripts, such as post function or listener scripts, to help achieve your requirement.
I hope this answer helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Benjamin,
I am glad it helped.
Could I please ask you to accept the answer to mark it as correct for other users to find?
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.