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

Behaviour and external API does not return correctly

Dear all,

I am trying to build a behaviour which convert a text field in a select list box by collecting data from an exteranal API.

For that I follow the samples provided in this link below :

Select List Conversions (

I have for that created a simple REST API call which collect VM information from Azure and which return the following sample data from POSTMAN


From my custom Rest endpoint, I need to return the *tags list items* in order to be visible into the Select List field of my behavior

The issue I met is that I do not know, or at least it is not so clear from sample on the way I should format the return response from the API in order that behavior gets the data

In my sample snipet code below, I need to return, as in the sample, a New JsonBuilder object based on my json return by the API but I could not get the correct syntax to replace in ???????? in order that my field slection contains items *com, aem, dispatcher* from tags element of my original return json above


Any idea ?

I am struggling this for a full week now and I am stuck, hoping you can help



1 answer

0 votes

The select conversion method need the JSON in very specific format.

So you'll need to prepare a return object with that format.

Based on what you provided, I'm expecting the vmInfo object returned by httpBuilder.request to look something like this (as you would deeclarie it in groovy)

location:"don't care",

So if I start with building a replacement variable with this data, I can use that to construct the output object

def vmInfo = [name:'dummy', location:"don't care", tags:[app:'appname', product:'aem', type:'dispatcher']]
//we're only interested in the tags ... I've opted to include both tag key and value sepearated by colon, but you can adjust that format
def tags = vmInfo.tags.collect{k,v-> "$k : $v"}

//normally, the query should come from your rest api with
//def query = queryParams.getFirst("query") as String
// but I used this for testing
def query = 'prod'
//this is the object we need to return
def singleSelectRet = [
items : tags.collect{tag ->
value: tag,
label: tag,
html: tag.replaceAll(/(?i)$query/) { "<b>${it}</b>" }
total : tags.size(),
footer : "Select a tag"
return Response.ok(new JsonBuilder(singleSelectRet).toString()).build()

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

208 views 1 4
Read article

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