I have a multiline text field. is it possible to run a post function with HTTP request and get the JSON response and show in the text field when I click on create an issue?is it possible to set the field value with the POST function by running an HTTP GET request behind the scenes and getting the response and parse it and update field value with JSON response?????please share a snippet it would be very helpful
Let me see if I understand correctly.
You want to create a new issue in jira. When you click the create button to submit the issue creation form, you would like to run a custom post-function script that will execute an HTTP GET request to some third party tool (perhaps using some attributes entered in the issue creation form as part of the request), then update the multiline custom field with the JSON response from the HTTP GET request.
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import groovy.json.JsonOutput
def customFieldId = 123456 //the ID of your multiline text field
def httpBuilder = new HTTPBuilder('http://example.com')
httpBuilder.request(Method.GET, ContentType.JSON) {
headers."your custom header" = "custom header value"
uri.path = '/path/to/endpoint'
uri.query = [mapOf: "keyvaluepairs"]
response.success = { resp, data ->
issueInputParameters.addCustomFieldValue(customFieldId,JsonOutput.toJson(data))
}
response.failure = {resp, data ->
//do something with the failed response
}
}
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.