cancel
Showing results for 
Search instead for 
Did you mean: 

Inject variable list of into a parameter.

AMacourek
Deputy Chef III
Deputy Chef III

I have a list of Ids in a variable:
{ObjectTypes:[6,118,119]}

 want to have this injected into a JSON parameter for a JIRA API call

{
"qlQuery": "objectTypeId IN ()"
}

I tried using the variable between the () and it did not like the formula.

The resulting JSON should be: 

{
"qlQuery": "objectTypeId IN (6,118,119)"
}

I could hard code this, but it is always better to be data driven.

5 REPLIES 5

gary1
Star Chef I
Star Chef I

If the JSON is encoded as a string you have to use string interpolation like this:

"{\"qlQuery\": \"objectTypeId IN (#{data pill goes here})\""

Seeing a screenshot of your recipe would be more helpful.

Here is the step:

image.png

I can put in the pure JSON, but I want the values of the array here.

If I do the following, it fails.

image.png

You probably don't want to use the "step output" data pill because that's going to insert the entire variable. You want to select the data pill within the variable that represent the value of ObjectTypes.

It also depends on how your previous step is configured. If ObjectTypes is truly an array, you can't just insert the array into the JSON because it will insert with [brackets]. You'll need to stringify it first because qlQuery is a string data type and you want your text to be formatted correctly.

Assuming you have a data pill for ObjectTypes, I would try this:

{
"qlQuery": "objectTypeId IN (#{[ObjectTypes data pill].join(',')})"
}

I tried the above and it worked fine. If it doesn't work on your end, I would need to see how you have step 7 configured.

I am still getting errors:

image.png

Here is the schema for step 7

 

image.png

And the values I am setting on initialization:

image.png