Using Search API how to get all WorkLogs

Vishal Biyani
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.
May 11, 2021

I am using Python and Jira REST APIs to get all the issues logged against a project and the worklogs corresponding to the issue

/rest/api/3/search
payload_dict['expand'] = []
payload_dict['jql'] = "project = TEST AND updated > '2020-01-01 00:00'"

field_list = [
"issuekey",
"issuetype",
"issuelinks",
"worklog"
]
payload_dict['maxResults'] = 100

When the worklog object is returned, i am getting below json object inside issues.fields.worklog. Since i am not getting the next Url for this nested worklog object, i am not sure how do i get remaining objects of the worklog, if it has more than 20.

Any suggestions will be helpful.

{
"startAt": 0,
"maxResults": 20,
"total": 200,
"worklogs": [
{

.

.

}

]

1 answer

1 accepted

1 vote
Answer accepted
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 14, 2021

Hi @Vishal Biyani ,

I would recommend you to use issue search endpoint for getting only list of issues and then Get issue worklog endpoint for getting worklogs for each found issue. There are query parameters like startAt, maxResults etc. available.

Vishal Biyani
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.
August 15, 2021

@Hana Kučerová Thanks Hana. This is exactly what i ended up doing this. So if issue search returns, total records in worklog as say 38, i am firing the Get issue worklog to startAt 21 and get the remaining work log items

Like Hana Kučerová likes this
Hemanth Lucky August 6, 2022

Hi @Vishal Biyani Did You figured out that issue.

If u Figured out issue please let me know. 

Thanks in advance

Vishal Biyani
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.
August 6, 2022

@Hemanth Lucky 

Below is the high level approach i used,

1. I used below end point to get 100 results at a time and looped through the result set.

/rest/api/3/search

 

2. Check  

if issue['fields']['worklog']['total'] > 20:
  Then use /rest/api/3/issue/{ret_issue['key']}/worklog end point to get worklogs starting from 21st record

Note: As per Step 1, issuekey value is available in the json response ({ret_issue['key']})

Hope this helps

Hemanth Lucky August 6, 2022

Hi @Vishal Biyani 

 

Thanks In Advance

Hemanth Lucky August 6, 2022

Hi @Vishal Biyani  

Vishal Biyani
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.
August 6, 2022

@Hemanth Lucky 

Looking forward to discus your doubts with you.

Let me know your email id, and i will message you.

Hemanth Lucky August 6, 2022

@Vishal Biyani  

Thanks in Advance

Hemanth Lucky August 6, 2022
Vishal Biyani
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.
August 6, 2022
Hemanth Lucky August 22, 2022

@Vishal Biyani Hi Bro

Now iam able to get the all the fields through rest api,, except the all worklogs..iam getting only 20 worklogs..can u please tell me the logic for that..

Vishal Biyani
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.
August 22, 2022
Hemanth Lucky August 22, 2022

@Vishal Biyani  Hi broo..

I tried this api. Iam able to give the range for Tickets and i am not able to give the range for Worklogs...

If you have any time will connect and discuss for this..

Thanks in Advance.

Hemanth Lucky August 22, 2022

@Vishal Biyani 

Bro Need ur Help....

Vishal Biyani
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.
August 24, 2022

Let's connect over weekend

Hemanth Lucky August 24, 2022

@Vishal Biyani Can u please connect Today, Almost Iam at the last stage,If u connect today it will be more helpful for me...

Suggest an answer

Log in or Sign up to answer