Get Time-Tracking information for Story that includes sub-tasks? Edited

Issue information in JSON format is available through the following REST call:

https://jira.[DOMAIN].com/rest/api/2/issue/[TICKET REFERENCE]

If the Issue is a Story with subtasks, the timetracking information returned by this REST call is either the following: 

timertracker1.png

- or -

timetracking2.png

- or -

timetracking3.png

But, if you goto the website version and check the "Include sub-tasks" checkbox, the timetracker then updates on the website's graphical side to include all the sub-tasks time together.

sub-task checkbox.gif

Is there a way to include this checkbox value in the REST call? Can I make a REST call to an Issue that includes the sub-tasks in the timertracking section? Are there parameters I can include in the GET request for the REST call to have this option enabled?

Thanks,

-Dan

1 answer

1 accepted

It doesn't look like the current REST API supporsts this operation.

For anyone reading this and needs a work around, you can scrape the HTML page for the information; it's messy, I know. In my environment, the "Include sub-tasks" is checked automatically when loading the page, so therefore, parsing the raw HTML gets me what I want.

(If the checkbox is not automatically checked for your environment, it becomes 10 times harder and you'll have to do some trickery with Javascript)

In my example, I only want the "Estimated" time that includes the sub-tasks. The "Estimated" time is located between <dd ...>...</dd> tags. If you search for the ID "tt_aggregate_values_orig" and grab the text between ">...<" you'll get your answer.

Here is some C# detailing this:

 

HttpResponseMessage response = client.GetAsync("https://jira.[DOMAIN].com/browse/" + issue).Result; 


string httpResult = Regex.Replace(response.Content.ReadAsStringAsync().Result, @"\t|\n|\r", String.Empty);


string[] capture = httpResult.Split(new string[] { "tt_aggregate_values_orig" }, StringSplitOptions.None);


string estimateScrape = capture.Length >= 2 ? Regex.Match(capture[1], @">(.+?)</dd>").Groups[1].Value.Trim() : ""; 

 

I have "capture.Length >= 2" because if there is no time on any of the sub-tasks and the story, this ID will not be present in the HTML. 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

650 views 6 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you