Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using match() on webResponse is not working as expected

Svante Gustafsson Björkegren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2025

Hey community,

I have run into an issue that gives me a mild headache. I am quite sure I am missing something basic but I cannot identify it. 

Background: I have read up an API response that looks like this:

{
"id": 27653,
"name": "System",
"color": "G200",
"editable": true
},
{
"id": 27654,
"name": "Completeness",
"color": "#36B37E",
"editable": true
},
{
"id": 27655,
"name": "Application",
"color": "R400",
"editable": true
},

What I need to do from here is to check if a block including a certain id exists. I have tried this:

{{webResponse.body.id.match("(27653)").size}}

which I expected should have returned 1, but it returns 0.

I have played around with the regex and found that is I match on another element in the block it works fine, like this:

 {{webResponse.body.name.match("(Compl.*)").size}}

returns 1 as expected. So I am thinking that it has to do with the format of the two values, number and string.

Any ideas how to make this .match() function with the numeric attribute id?

Thnx in advance!

Cheers,
// Svante

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2025

Hi @Svante Gustafsson Björkegren 

I wonder if the JSON parsing from the webResponse is detecting the type as number rather than text type.  You could check that by forcing conversion to text with format() prior to the match() function:

{{webResponse.body.id.format("#").match("(27653)").size}}

 

Kind regards,
Bill

 

UPDATED: as the text function apparently does not work with number data.

 

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2025

Hi @Svante Gustafsson Björkegren 

What if you would try the following.

{{#webResponse.body}}{{if(equals(id,"27653"), 1)}}{{/}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events