Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Setting organisation into issue with API call inside script runner

Hello everyone,

I am migration our server instance to the cloud and I am having issues with setting up the service management project correctly.

The goal is, that the script runner script should set the organsiation based on the email domain. 

I know that this already works with automation, but from my point of view it is not fully thought out and not usable for us as we have customers working with different domains.

So I created a script with this function


public void setOrganisationToIssue(String issueKey, String organisationID) {

    def builder = new JsonBuilder()

    def root = builder {

        fields {

            customfield_10002([id: organisationID])




    def jsonString = builder.toPrettyString()

    def correctedJson = [fields: [customfield_10002: [[id: 156]]]]

    def correctedJsonString = new JsonBuilder(correctedJson).toPrettyString()

def resp = put("/rest/api/2/issue/SD-104801")

        .header('Content-Type', 'application/json')





With this example the result of the json looks like this


    "fields": {
        "customfield_10002": [
                "id": 156

But I get this error message

body: {"errorMessages":[],"errors":{"customfield_10002":"Die Organisations-ID muss eine Zahl sein."}}

That means, that the organisation ID must be a number.


I tried a bunch of different things without any luck. Also I wasn't able to use the json builder, because he removed the arrays and I got a message, that setting the organisation needs to use an array.

1 answer

Its seems like, that the json needs to look like this

    "fields": {
        "customfield_10002": [156]
At least with postman it works

Suggest an answer

Log in or Sign up to answer
Site Admin
AUG Leaders

Atlassian Community Events