Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

API Put call via ScriptRunner to update external field


Hello all,
we are currently populating an external system with the Jira ID via a put call. We need this to be able to send updates from this system to the respective Jira issue.

Thus, when creating the issue via workflow, we want to trigger a script runner script which will then perform the put post. However, we are currently still getting an error message, the body is intentionally empty for now for testing purposes. The endpoint differs to a field value which is filled by the creation, this is happening via post call from this external system. 

I suspect the syntax of my script does not fit.

package utils
import groovy.json.JsonOutput




import com.atlassian.jira.issue.Issue

import com.atlassian.jira.component.ComponentAccessor

public class UpdateFieldValuePut{

public static String postResponse(Issue issue)


def hostUrl = ""

def customField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_12727")

def strErgebnis = issue.getCustomFieldValue(customField).toString()

def endpointAndQuery = "" +strErgebnis+".json"

        // Turn the data will be sent into JSON, the HTTP requests specify in the header to accept application/JSON

        // If the API accepts different types then you can change this and format the data accordingly

def bodyJson = JsonOutput.toJson([data"<YOUR DATA>"


    def client = new RESTClient(hostUrl)


        'Accept'       : ContentType.JSON,

            // If authentication mechanism of the API is Basic Authentication, 'Authorization' header with username and password encoded as Base 64 can be specified here

        'Authorization': "Basic ${'APIToken:x'.bytes.encodeBase64()}"


    client.handler.success = { HttpResponseDecorator response, json ->



    client.handler.failure = { HttpResponseDecorator response ->

        // Failure can be handled here

        log.error response.entity.content.text






        path: endpointAndQuery,





Best regards,


1 answer

Hi @Tobias

Could you please clarify, when you mentioned External System, i.e. are you referring to an external REST Service?

If so, you could try to use this sample code provided in the Adaptavist Library.   

I hope this helps to answer your question. :)


Thank you and Kind Regards,


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