def issueKey = 'QAMEW-14'
def logTest=get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
logger.info("test ======>>>>> "+logTest.body.fields.status.name)
def result = put('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.body([
fields:[
status:[ name:"Backlog"
]
]
]
)
.asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}
I keep getting this error...why:
PUT request to /rest/api/2/issue/QAMEW-14 returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"status":"Field 'status' cannot be set. It is not on the appropriate screen, or unknown."}} Serializing object into 'interface java.util.Map' Please use the ScriptRunner user to complete this task not the Initiating User. See https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue for more information. If you are using the ScriptRunner user then check the Field Configuration
Hello @Anh A welcome to the Community!
I'm not quite what you're trying to do exactly, but looking at this I'm guessing you're trying to change the status of a specific issue? If that's the case, you'll probably want to use the transition issue request.
Hope this helps
Yes thank you for replying @Sam Nadarajan , I am trying to change the body.fields.status.name. Say it is name "in progress" how do I move it to my "Backlog" status?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it.
You actually cannot change the status field directly like you can with other custom fields. To do that you would need to use the HttpRequest for transition issue (that I linked above) instead of the edit issue.
Here's a similar thread that you should also reference.
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Sam Nadarajan it does kind of make sense to me. I guessing it is just my api call? My apologies, I am not that great at coding.
def result = post('/rest/api/2/issue/'+issueKey+'/transitions')
.header('Content-Type', 'application/json')
.body([transition: [id: 91]]
)
.asString()
To replace my put call above?
This is what the api returns I see
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for the late response, that call looks right, I'm assuming that transition 91 is the status change you want to make?
I can't see what the API return in your above response, would you mind posting it?
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.