Formatting a Rest API HTTP request in my Automation

Hello, I’m a game design lead using automations to track worklogs in our project. I’m somewhat comfortable with automations in general for simple things but Rest API syntax is out of my wheelhouse so looking for help.

We use the 3rd party Clockwork app for time tracking and thier support team were able to provide me the request below. The goal is to grab a Epic and it’s children and return the total time spent on them together. That value is added to a custom field on the Epic. I’d like to modify the request to ignore children that are parented to the Epic but are from other projects. Any help would be appreciated, thank you!

This is the request I was given:
https://[domainnamehere].atlassian.net/rest/api/2/search?jql=parentEpic%3D{{issue.key}}%20or%20parent%3D{{issue.key}}&fields=timespent

Here is the surrounding automation:

Hello @WyattGetzen

Firstly, not to be rude, but questions about using Jira’s inbuilt automation and constructing JQL queries is not considered to be ‘development’ and are best asked in the Atlassian Public Community forums. However, I can provide the answer on this occasion.

  1. You can’t do both in the same automation rule, you would need two separate rules.
  2. You said you want issues ‘in other projects’ but your existing JQL doesn’t specify a Project, so its scope already is all projects.
  3. Epics belong to specific Projects, so you have caused the scope to be constrained to a particular Project by asking for issues parented by a particular Epic
  4. In Jira Cloud, the field parentEpic was deprecated ages ago and was replaced with parent, so asking for both in the same JQL is redundant.

So, based on this, a JQL query to request issues that are not parented by a particular Epic, and are also not from the same Project as the Epic belongs to, would be:

https://[domainnamehere].atlassian.net/rest/api/2/search?jql=project!=[theepicsprojectkeyhere] and parent!={{issue.key}}&fields=timespent

Have fun

1 Like

Hello, @sunnyape. Thank you for your reply! Apologies for the wrong forum I realized this late yesterday and didn’t have time to correct it.

The automation in the picture does contain a edit issue action at the bottom which got cropped off (I meant to include it in text) and this automation is already working for us within one rule. The edit issue action is worded as follows:

{
“fields”: {
“Total time”:{{#=}}
{{webhookResponse.body.issues.fields.timespent.join(“+”)}}
{{/}}
}
}

I’m sorry if I wasn’t clear but the nature of my request does not line up with what you described it to be. We have bugs / tasks from other projects whose parent is an Epic in the project my team uses. To describe this a bit more clearly my team handles quest design and each epic is one quest. But the team finds it valuable to have bugs and art assets (from QA and Art projects) parented to the Quest Epic in our project.

When the request is run on the Epic in my project, the time value it returns includes time spent on those bugs / tasks from the other projects.

What I’d like the request to do is ignore those children from other projects when getting the time from each child card.

Hopefully this makes my request more clear, thank you!

Using Epics in one project to ‘sum up’ Issues from other Projects is generally considered a Bad Thing, because of the exact problems you have encountered, but anyhow…

Then all you need to do is specify in your JQL to find those issues that have that Epic as their parent AND are in the same Project as that Epic. That would be:

jql=parent={{issue.key}} AND project=[theEpicsProjectKeyHere]