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

Unable to iterate using WebhookResponse and Advance Branching

Amish Khatri February 16, 2024

I have a web service that will return data in the form of JSON depicted beow.

I have created a new JIRA Automation Rule that uses "Send Web Request" on Issue transition from "To Do" to "In Progress".

When I use "variterate" to get "WebhookResponses.last.body" I indeed receive data but the problem is the rule doesn't reiterate. I expect to iterate under "For Each" steps in Advance Branching, but instead, it just goes inside once that's it and comes out, though I have 4 test objects in JSON. I am seeking help to fix this issue.  

(Figure 1)

jira-rule1.jpg

The below steps "desc- {{variterate.description}}
- {{variterate.get(0).description}}
- {{variterate[0].description}}
- {{variterate.0.description}} "

Doesnt print anything after multiple tries. 

(Figure 2)

jira-rule2.jpg

Web Service Response :

[
{
"title": "Happy Path - Recurring Payment Setup",
"description": "User sets up a recurring payment with valid details",
"expectedResult": "System saves the payment details and sets up the recurring payment successfully"
},
{
"title": "Expected Error - Missing Payment Details",
"description": "User tries to set up a recurring payment without entering all the required payment details",
"expectedResult": "System shows an error message about missing payment details"
},
{
"title": "Expected Error - Invalid Payment Details",
"description": "User enters invalid payment details while setting up a recurring payment",
"expectedResult": "System shows an error message about invalid payment details"
},
{
"title": "Test Edge Cases - Maximum Recurring Payments",
"description": "User tries to set up more than the maximum allowed recurring payments",
"expectedResult": "System rejects the request and shows an error message"
},
{
"title": "Test Edge Cases - Minimum Recurring Payments",
"description": "User tries to set up the minimum allowed recurring payments",
"expectedResult": "System saves the payment details and sets up the recurring payment successfully"
}
]

2 answers

1 accepted

1 vote
Answer accepted
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.
February 19, 2024

Hi @Amish Khatri  ( @ameesh khatri  )

It appears you are using two different accounts, so I mentioned both.

 

Have you confirmed the response body is both valid JSON and the automation rule recognizes it as a list of values?

You can do this with a test, writing this expression to the audit log after the Send Web Request action:

the count of items in the body is: {{webResponse.body.size|0}}

If the result is not the record count you expect, the body content is not parsing as a list.  Instead it is likely plain text, or an array represented as text.

 

If it is not a list, you may use text functions, such as match() or split() to first parse the body into a list for use in the branch.  Once inside of your branch you may use additional text functions to examine the data you believed to be represented as JSON fields.  To learn more about those functions, please review this documentation.

 

Kind regards,
Bill

ameesh khatri February 19, 2024

Let me try this @Bill Sheboy to find out whether the return JSON from the service is a list or just a text. 

0 votes
Kalyan Sattaluri
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.
February 16, 2024

<EDIT> - Below discussion is not valid for this use case because Jira wasnt able to pick @Amish Khatri  response was valid JSON. Need to use .match logic as suggested by @Bill Sheboy  in such cases.

 

 


Hello @Amish Khatri 

 

Please post the audit log of {{WebhookResponses.body}} so we can understand whats going on.

Cause its unclear if the JSON response you posted, is it output of log action of {{WebhookResponses.last.body}} or what... cause thats what you are logging in in your first screenshot.

So please clarify that first.

My immediate suggestion without knowing above point is, your advanced branch should be  {{WebhookResponses.body}} .. 

Also, for rules like these, dont directly create/update issues.

First log data every where, including the branch so you can confirm you have the data at hand before updating issues.

Finally  just FYI, once inside a branch, you reference fields with dot notation... so  {{variterate.description}} to pull out the description.

Amish Khatri February 16, 2024

@Kalyan Sattaluri   I tried with {{Webhookresponses.body}}} and was able to print so the response is coming but under advanced branching the "variterate.description" doesn't capture .See the attached screenshots for the reference. 

Kalyan Sattaluri
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.
February 16, 2024

@Amish Khatri 

Sorry, lets start over.

What are you calling in your "send web request"?

And right after you have made the send web request call, can you log {{webResponse.body}} and post the JSON here.

Amish Khatri February 16, 2024

@Kalyan Sattaluri these are screenshots which generated comments on story where you can see "variterate.description" hasn't generated anything. Another screenshot is about response from webhookresponses.body

jira-rule3.jpgjira-rule4.jpg

Amish Khatri February 16, 2024

Hello @Kalyan Sattaluri below is the steps to call "send web request" and indeed receive the above JSON output.

jira-rule5.jpg

Kalyan Sattaluri
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.
February 16, 2024

@Amish Khatri 

Instead of webhookresponses.body try webresponse.body.

So can you...  right after "send web request", log {{webresponse.body}}  like I have it below and share the JSON.

 

 

image.png

Kalyan Sattaluri
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.
February 16, 2024

@Amish Khatri 

Make your rule like I have below and share complete audit log. Please pay attention to highlighted steps and dont bother updating comments yet.

image.png

Like Bill Sheboy likes this
ameesh khatri February 16, 2024

Below are comment logs received from the automation rule @Kalyan Sattaluri . You can see " desc - " which means, it doesnt print variterate.description however it has printed Webhookresponses.body as "WebhookResponses.body"

jira-rule1.jpg

Kalyan Sattaluri February 16, 2024

@Amish Khatri  @ameesh khatri 

Did you see my earlier posts and what changes I suggested you do to your rules? Your requirement can be solved simply if you just follow those steps. 

ameesh khatri February 16, 2024

@Kalyan Sattaluri  tried the way you asked to change but not printing after changing webresponse.body.

jira-rule2.jpgjira-rule3.jpg

Kalyan Sattaluri
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.
February 17, 2024

@Amish Khatri @ameesh khatri 

I am assuming {{webresponse.body}} gave you the JSON you posted in your first post.

So Unless you post full screenshot of your audit logs, we cannot tell or help. 

Just log it like I have it in my screenshot.

So, I cannot engage further unless you post screenshot of your full rule/complete audit log.

Audit log should specifically show {{webresponse.body}} captured before you branch.

And for the love of god, please stop updating comments and posting that screenshot alone. It tells nothing.

 

 

ameesh khatri February 19, 2024

Hello @Kalyan Sattaluri , Below is the complete audit log which you requested. I have changed the rule as per your suggestion with {{webresponse.body}} . Though you see the first box of rule in the snap has clipped, but to fit the entire snapshot I did my best to get the entire snapshot. The first step in the rule is the "send web request" only. 

Apology, if you find multiple screenshots without comments before, but my machine has some slowness so my previous replies were just screen shots. 

Here two snapshots, rule details and audit log respectively. Even after using webresponse.body "variterate.description" doesnt provide any value. 

jira-rule9.jpgjira-rule8.jpg

Kalyan Sattaluri
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.
February 19, 2024

@Amish Khatri @ameesh khatri 

There is no reason what I suggested should not work.

Even though I have asked you to log both outside and inside the branch, You are NOT logging me details inside the branch and instead putting comments directly in rule.

When you add comments to tickets which have smart values, Audit log currently does not render smart values. So it tells nothing.

And we just keep going back and forth.

Again - What I have suggested has been proven to work a thousand plus time by others in this forum. Thats how I have leant and I know it works because I have used the same logic for my rules. Its not something I have invented.

My suggestion is, take a break from this thing. Come back after some time, reread this thread fully & carefully, especially my last few posts and implement this rule from scratch.

 

 

 

 

ameesh khatri February 19, 2024

I am facing an issue with the Smart Value not rendering the value @Kalyan Sattaluri  when the JSON response contains 3-4 nodes. According to my understanding, variterate should iterate the same number of times as the nodes, but it seems to iterate only once, which is perplexing.

Regarding the audit logs, I sent them to you as requested. However, I'm uncertain about what might be missing since the entire rule audit, both inside and outside the branch, is visible in the screenshot. Is there anything else you would like me to provide?

I am aware that others may have successfully implemented similar solutions. The rule I am using is quite straightforward, and I am puzzled by the ongoing issue over the past 3-4 days.

I have thoroughly reviewed this thread multiple times and have ensured that I provided all the requested information. Nevertheless, I will reevaluate it once again to see if there is anything I might have missed.

Kalyan Sattaluri
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.
February 19, 2024

If my sample JSON is like below, whose structure is exactly  just like yours 

[
{
"self": "https://trainjira002.atlassian.net/rest/api/3/version/10001",
"id": "10001",
"description": "MY DESCRIPTION 4",
"name": "RELEASE 4",
"archived": false,
"released": false,
"projectId": 10000
},
{
"self": "https://trainjira002.atlassian.net/rest/api/3/version/10002",
"id": "10002",
"description": "MY DESCRIPTION 3",
"name": "RELEASE 3",
"archived": false,
"released": false,
"projectId": 10000
},
{
"self": "https://trainjira002.atlassian.net/rest/api/3/version/10003",
"id": "10003",
"description": "MY DESCRIPTION 2",
"name": "RELEASE 2",
"archived": false,
"released": false,
"projectId": 10000
},
{
"self": "https://trainjira002.atlassian.net/rest/api/3/version/10004",
"id": "10004",
"description": "MY DESCRIPTION 1",
"name": "RELEASE 1",
"archived": false,
"released": false,
"projectId": 10000
}
]

My rule is like below, (as I have suggested to you):

image.png

Then my audit log is like below: (notice I am logging {{variterate.description}} inside branch so I know value is getting populated)

image.png

 

My Final Output is like below:

image.png

 

Your JSON structure is no different than what I have. 

That is why I asked you to LOG the {{variterate.description}} inside the branch as well, which you dont for some reason.

Maybe post this thread again so others can help cause obviosly I am not able to.

ameesh khatri February 20, 2024

@Kalyan Sattaluri  I replicated the way you created the rule and have seen the rule is failing because {{variterate.description}} is getting blank. Absolutely frustrating for me :( 

Here are the latest snapshots:

Yesterday when I ran {{webResponse.body.size}} it shows blank as @Bill Sheboy  asked to check which means there is definately problem with JSON list like response coming from the service. 

If the iteration rule doesnt work I need to check match() or string functions which I have to explore it.  

jira-rule11.jpgjira-rule10.jpg

Kalyan Sattaluri
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.
February 20, 2024

@Amish Khatri @ameesh khatri 

Maybe its those leading and ending square brackets making it JSON array which Jira is not able to parse. I can think of 4 different options of varying complexity.

  1. Try to send this web response you have received to an incoming webhook unchanged and see if Jira can parse it. To do this, create a new rule with trigger as incoming webhook, grab the URL and then, in your existing rule, once you have made the web request, send this {{webreponse.body}} in payload to the URL, and finally, in the new rule, check {{webhookData.size}}
  2. Same as above, but before making the call to webhook, remove the leading and ending square brackets, like {{webreponse.body.remove("[").remove("]")}} because they seem to be the issue. And check if you can parse the JSON.
  3. As @Bill Sheboy has suggested, you can parse the text and extract your values. See HERE for example
  4. Finally, see if you have another end point which gives same data but in a JSON which Jira can parse.

I would make sure #4 is an option, if not, quickly check  #1 & #2 if they work, if not, you can solve it by #3.

ameesh khatri February 21, 2024

Hello @Kalyan Sattaluri  and @Bill Sheboy 

The issue is fixed by #3 suggested by @Kalyan Sattaluri . THANK YOU SO MUCH for your extended help in resolution. Really Appreciated your help on this issue. 

I have another problem of increasing "send web request", but I know right now its not feasible in Jira rules to increase timeout, nevertheless will check with web service publisher to optimize web service response time.  

Kalyan Sattaluri
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.
February 23, 2024

Hello @Amish Khatri  @ameesh khatri 

Great to hear you got it resolved.

Can you please accept Bill's response as answer cause that was the solution and when you get a chance, post your method for future folks to understand the process to take...

Amish Khatri February 27, 2024

Done ! @Kalyan Sattaluri 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events