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!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

having issues accessing the data in a returned json payload when configuring a rest endpoint

Hi all,

I am configuring a rest endpoint to populate a custom field with the results of an external API, as explained in the documentation for "Select List Conversions" in scriptrunner (

The issue I am having is that when I test the API in a browser, as explained in the document, I am getting an empty value:



That is most likely because I might be missing something in the loop where the actual values are gathered:

rt = [
items : persons["response.persons"].collect { Map person ->
def personfirstName = person.core?."firstName"
value: personfirstName,


Here is the extract of the jason payload:

"response": {
    "noOfRecords": 10,
    "apiVersion": "3.0",

          { "omitNullFields": "true", "limit": "10", "q": "pappas", "offset": "1" }

    "persons": [
        "lastUpdateDate": "2019-08-29T09:44:30Z",
         "core": {
                     "gocOfficeCode": "FIR",
                     "gocOfficeClusterCode": "FI",
                     "gocDepartmentId": 58034,
                     "jobRoleSubCategoryName": "n/a",
                     "jobRoleSubCategoryId": 1393714,
                     "firstName": "Michael",

I need to loop on the "persons" array to get the value for "firstName", which is under "core". And the "persons" array is under "response".

In the example in the documentation for the github repos, "items" is an array which is not under anything else, but in my case, "persons" array is under "response" so I am not quite sure how to access that.

Thank you for your assistance

1 answer

1 accepted

0 votes
Answer accepted

I re-created your json in a map object with only the pertinent information for testing

def resp = [

Then, I can get this correctly formatted output like this:

def query = "2" //as an example search criteria entered by the user to be bolded in the drop down
def rt = [
items: resp.persons.collect{person->
def html = ""
if (query) {
html= person.core?.firstName.replaceAll(/(?i)$query/) { "<b>${it}</b>" }
[value:person.core?.firstName, label:person.core?.firstName, html:html]

 When I convert rt to a Json, I get the following:


Hi @Peter-Dave Sheehan  that worked...thank that I have your attention :-) I need some assistance with something related to that same API. Now I need to pass that JSON response as the query parameter for another API I need to invoke with the GET method. Using your same JSON response example above,  name1, name2, name3, etc are codes and I need to query another API to get the actual names corresponding to those codes. Something like this:


q: "projectId: ("name1" OR "name2" OR ....)

a colleague of mine sent me a similar code in Java but I am not sure how to convert that to groovy so scriptrunner can take it:

q: `projectId:(${ => assignment.projectId).join(" OR ")})`


assignment object is coming from the previous API and I need to query another API with that assignment response.


Any assistance is greatly appreciated.


Thank you very much

Can you share some sample code around how you are calling that GET method in the other API?

But if you are just trying to make a string of names with OR as separators:

"${resp.persons.collect{it.core.firstName}.join(' OR ')}"

Hi @Peter-Dave Sheehan  thank you for your reply...I figured it out. And yes, you are in the right track. I did use the join method along some  other string methods to get the 'q' parameter for the next API and I got it working. I do have another issue though, related to this, since the behavior associated to this rest end point works ok in jira but not that really ok in JSD. I will create another question in the Atlassian Community if necessary for that issue but what is happening is:

- when typing in the field in jira, the list of values shows the values matching the 4 characters typed (the way is supposed to work).

- when typing in the field in jira service desk, the list of values shows ALL the values being returned by the rest end point, instead of the values matching the 4 characters typed.


Here is the behavior, which is actually a copy of the behavior in the select list conversion documentation in scriptrunner:


getFieldByName("Test Text Field").convertToMultiSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/getProjectNames",
query: true, // keep going back to the sever for each keystroke
minQueryLength: 4,
keyInputPeriod: 500,
formatResponse: "general",


Any idea how to fix that?


Thank you

Sorry... not much experience yet with scriptrunner and JSD. No I have no idea here.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events