Forums

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

Jira Automation: Counting Issues with JQL API via Send Web Request

simonlee September 8, 2024

Hi, I'm using Jira Cloud in a company-managed project and trying to calculate the progress percentage of parent issues based on the status of their child issues in Jira Automation.

Here's what I'm aiming to do:

  1. Trigger the rule when a child issue is created, edited, or deleted.
  2. Use the trigger to get the parent issue key.
  3. If the parent exists, count the child issues using the "Count issues using JQL" API: Count issues using JQL API
    The reason I am using the REST API is that the Lookup Issues action in Jira Automation has a limit of 100 issues. I have some initiatives with more than 100 epics, so I need to bypass that limitation.
  4. The API works fine when I use cURL, and it returns the correct count.
  5. However, when I attempt to use this API in Jira Automation, the count value returned is always 0.

 

Request payload:

headers

Accept: Application/JSON
Content-Type: Application/JSON


custom data

{"jql": "project=kdev and parent={{triggerissue.parent.key}}"}

or

{"jql": "project=kdev"}

Response payload:

{ "count": 0 } // count is always 0, response status is 200 = success

 

Even though I know there are issues that match the JQL query, the response count is always 0 when used in Jira Automation.

Has anyone successfully implemented this, or can provide guidance on how to get the correct count of child issues through Jira Automation?

Any help would be greatly appreciated!

2 answers

1 accepted

1 vote
Answer accepted
Stuart Wosika
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 12, 2024

Take a look at my response (to my own ticket actually :-) ) : 

https://community.atlassian.com/t5/Automation-questions/I-want-to-create-a-total-sum-for-a-custom-field-Jira-Data-Center/qaq-p/2809379#M11723

I had a similar issue getting 200 response so the API call was somehow quietly erroring.  I resolved this in my case with the header "authorization" adding bearer.  This is what I am using for authorisation.

Hope this helps.

 

p.s. Have you got {{triggerissue.parent.key}} working in the body of "custom data".   

 

simonlee September 13, 2024

@Stuart Wosika was right, the Authorization header was indeed the source of the problem.

Also, {{triggerissue.parent.key}} is working well. Here is my final custom data for two cases:

{"jql": "parent={{triggerIssue.parent.key}}"}
{"jql": "parent={{triggerIssue.parent.key}} and statusCategory=Done"}


One thing I’m curious about is why the response was 200 success. If the issue was related to authentication, shouldn't it have returned a 401 unauthorized instead?

Like Stuart Wosika likes this
Pablo Vergara
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 23, 2024

Thank you @Stuart Wosika! - What an unexpected thing! I imagine no auth token header is required if the rule actor has the proper access to browse the issues involved.

Or, I would expect the Jira Cloud API to respond properly if that authorization is required and not just a 0 count. Do you agree they need to enhance this endpoint? I bet so.

Thanks again for your addition to my response here!

- Pablo

0 votes
Pablo Vergara
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 12, 2024

Hi @simonlee

Welcome to the community!

I was curious about your case and decided to take some tests. Unfortunately, I got the same results when using the /rest/api/2/search/approximate-count API endpoint.

It seems there is a problem when the request is sent through Automation for Jira, so I suspect the Custom data is not correctly sent over as the request's payload, and it always returns 0.

As you can see in the captures below, even when a specific issue key is sent as part of the JQL, the count remains 0. That would be absurd, knowing the issue exists.

1.png

2.png

When I try using the JMWE Nunjucks tester (and callJira filter to send the request), the response is OK, and the count is 1, as it should be. This confirms it's something specifically with A4J that's failing.

3.png

I would suggest opening a bug report with Atlassian. They should check why we have this inconsistency.

I'm afraid there is not much else we can do regarding this behavior.

- Pablo / SSE - ServiceRocket

simonlee September 13, 2024

Thank you so much for the help. The Authorization header was the source of the problem.

Suggest an answer

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

Atlassian Community Events