Hi guys,
I have this code which eventually should be in a scriptrunner listener. Right now I am testing it in the console.
For some reason although I manage to get the keys for the issues I cannot perform the transition or change the status. Can someone advise where is the problem?
The error messages I receive are:
When I try the put transition request I get:
POST /rest/api/2/issue/AKD-469/transitions asObject Request Duration: 162ms
POST request to /rest/api/2/issue/AKD-469/transitions returned an error code: status: 400 - Bad Request
body: {errorMessages=[Can't move (AKD-469). You might not have permission, or the issue is missing required information. If you keep having this problem, contact your Jira Administrator.], errors={}}
When I try the put status request I get:
PUT /rest/api/2/issue/AKD-469?overrideScreenSecurity=true asString Request Duration: 984ms
PUT request to /rest/api/2/issue/AKD-469?overrideScreenSecurity=true returned an error code: status: 403 - Forbidden
body: {"errorMessages":["Connect app users with a\”admin\" permission and Forge app users with the \"manage:jira-configuration\" scope can override screen security."],"errors":{}}
The complete code is here and (it contains both the put and post requests but I comment one of them each time so only the other is executed.)
def issueKey = 'AKD-452' //issue.key
def newTransitionId = '721'
def newStatus = 'On Staging'
def newStatusID = 10005
def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
// Find the linked issues
def linkedIssuesKey = result.body.fields.issuelinks.inwardIssue.key
def length = linkedIssuesKey.size()
for (i in 0..<length) {
def submit = put("/rest/api/2/issue/${linkedIssuesKey[i]}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
.body([
fields:[
status:[name:newStatus]
]
])
.asString()
return submit
// def transitionIssue = post("/rest/api/2/issue/${linkedIssuesKey[i]}/transitions")
// .header("Content-Type", "application/json")
// .body([transition: [id: newTransitionId]])
// .asObject(Map)
// Log out the issues transitioned or which failed to be transitioned
logger.info("Transition ${newTransitionId} performed for the ${linkedIssuesKey[i]} issue")
// return ['Issue:', ${linkedIssuesKey[i]}, 'was moved to On "Staging"'];
}