Hello All
In the scriptrunner listener for issue created when I append $${issue.key} it is not working in put function, however if I hard code the key like XXX-152 it works
I am trying to update the issue.
What is the correct way to update issue in scriptrunner listener. Please let me know
This does not work
def issueKey = issue.key
def result = put('/rest/api/2/issue/${issue.key}') .header('Content-Type', 'application/json') .body([ fields:[ summary: newSummary ] ])
This works with hardcoded key
//def issueKey = 'DWS-152'
def issueKey = issue.key
logger.info("${issueKey} or ${issue.key}")
def newSummary = 'Updated by a script'
def result = put('/rest/api/2/issue/XXX-166')
.header('Content-Type', 'application/json')
.body([
fields:[
summary: newSummary
]
])
.asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}
Please let me know.
Abe
Hi @AbrahamA
Can you try this
def issueKey = issue.key
def newSummary = 'Updated by a script'
def result = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields:[
summary: newSummary
]
])
.asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}
If I use ${issueKey} as part of put URL here is what I get
2 2023-03-28 03:14:50.429 INFO - PUT /rest/api/2/issue/${issueKey} asString Request Duration: 14ms 2023-03-28 03:14:50.434 ERROR - java.net.URISyntaxException: Illegal character in path at index 110: https://us.argon.polaris.connect.product.adaptavist.com/proxy-service/rest/api/1/jira/proxy/rest/api/2/issue/${issueKey} 2023-03-28 03:14:50.448 ERROR - Class: com.adaptavist.sr.cloud.events.WebhookExecution, Config: null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay @AbrahamA then the issue may be something else
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.