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

Search in Webhook Response and get a specific value back

Martin Müller May 16, 2022

Hi,

 

i've got a little problem using smartvalues in my jira automation webhook. 

 

I'm using 

{{webhookResponse.body.additionalInformation.fields.first}}

and receive

{id=33, type=TEXT, values=[21077]}, {id=39, type=TEXT, values=[PG-FBL]}

I'm able to get the values with 

{{webhookResponse.body.additionalInformation.fields.first.values.get(0).jsonEncode}}

{{webhookResponse.body.additionalInformation.fields.first.values.get(1).jsonEncode}}

and receive 

21077

PG-FBL

Now iam creating a new Issue where those values are matched to some customfields.

 

The Problem is, sometimes the foreign system where i get the data from, responds with more then those 2 values and in a different order, so i cant match them right.

 

Is there any possibility to search for the id (id=33 and (id=39) and only get the value back? 

 

Best regards

 

Martin

 

1 answer

0 votes
Filipi Lima
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 17, 2022

Hi, Martin,

One alternative would be to venture into regex matching with the match() function.

See the example from this page:

Let me know if that doesn't make sense but the idea would be to match to different regex using the ID as an anchor.

Filipi Lima
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 17, 2022
{{webhookResponse.body.additionalInformation.fields.first.match("id=33, type=TEXT, values=\[(.*)\]")}}

I can't test it right not, but hopefully that should give you a better idea of what I meant! 

Martin Müller May 19, 2022

Hi Filipi,

 

it doesnt work. i have a question for testing:

 

{{webhookResponses.get(1).body.additionalInformation.fields.first.match(".*(\d).*")}}

 

This should give ma a digit back, right? This doesnt work as well. The log is empty for your command and in my test as well.  

 

{{webhookResponses.get(1).body.additionalInformation.fields.first}}

returns

 {id=33, type=TEXT, values=[21077]}, {id=39, type=TEXT, values=[PG-OBL]}

 

I even tried this

 

{{webhookResponses.get(1).body.additionalInformation.fields.first.get(0).match(".*(\d).*")}}

log still emtpy. 

 

{{webhookResponses.get(1).body.additionalInformation.fields.first.get(0)}}

returns

 {id=33, type=TEXT, values=[21077]}

 

Maybe you have another idea? Would appreciate it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events