It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

how to update a customfield value by running http request in post function?

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

1 answer

0 votes

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 groovy.json.JsonOutput

def customFieldId = 123456 //the ID of your multiline text field

def httpBuilder = new HTTPBuilder('')
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 ->
response.failure = {resp, data ->
//do something with the failed response

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you