Forums

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

How to get the key instead of value in the json response in the webhook response?

Shruti Shrivastava January 1, 2024

I have a query regarding how to handle webhook response i want to get the key instead of value in the json response. I have a scenario where I am sending an email to leadership showing the committed and completed story points (velocity) for the last 6 sprints.

Following is the API call I am using -

rest/greenhopper/1.0/rapid/charts/Velocity?rapidViewId=(id)

This is giving me the correct response but sprint details and committed and completed story points are displayed separately in the json and cannot be mapped together because the order is different.

So now I am trying to do the following:

1. Go to the first sprint, get the details like name, goal etc and then save sprint id in the variable - sprintID.

Create Variable:

sprintID = {{webhookResponse.body.sprints.id.get(1)}}

// Actual value in json response 108055 (this keeps on changing every sprint)

2. Use the "sprintID" variable in the email response like

<td>{{webhookResponse.body.velocityStatEntries.{{sprintID}}.estimated.value}}</td>

but this is not working.

Alternatively, I also thought to do something like

{{#webhookResponse.body.velocityStatEntries}}

{{#if(JSONKEY.equals(sprintID))}}

// JSONKEY actual value 108055 

<td>JSONKEY.estimated.value</td>

JSON RESPONSE looks something like this:

{

"sprints":[

{sprint 1details} like id (108056), name, goal etc.,

{sprint 2 details},

...

{sprint 7 details}

],

"velocityStatEntries":{

"108055":{

"estimated":{

"value":34.0,

"text":"34.0",

}}

}

The sprint and their velocity order is different not at the same position and order. Some please help me with the solution.

Due to security reasons, I cannot share the SS of rule or json response.

 

 

1 answer

0 votes
Shruti Shrivastava January 4, 2024

@Bill Sheboy Hi Bill,

Can you please help me on this?

Suggest an answer

Log in or Sign up to answer