Get details of the users using jira API

Rashi Goyal November 9, 2020

Hi Team,

I want to fetch the details of the users programmatically who have logged less than 8hrs in a day.

Details must contain those users also who didn't log even a single minute i.e. 0.

Can anyone suggest to me the API to implement this?

Thanks in advance. Looking for the response asap.

@Warren any help from your side?

@Bogdan Gorka 

Right now the URL I am using is: https://xyz.net/rest/api/2/search?jql=project=" . $project['project_key'] . "&startAt=0&expand=changelog

This is working on the basis of the project keys. Everything is working fine but the major glitch is that here I am not getting information about the users who didn't log their hours. To overcome this I thought to loop the URL through users instead of projects. But I am not getting any hint on how to pass username in my URL to get the basic details i.e. their name, logged hours & date.

Someone, please guide I am not able to overcome this issue.

Rashi

1 answer

0 votes
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 16, 2020

Hello @Rashi Goyal ,

Thanks for reaching out, and one thing to consider here with JQL results is that a value will only be returned if an entry is present.  So if a user does not enter a value for the time spent, to add an entry to the worklog then nothing will be returned per a query as you would be searching for a non-existent value.   

to correct for this you would need to script in a search that returned a search query for a day meeting all the criteria, and if no results are found manually enter a value of "0" for the time spent.

Your idea to overcome this by looping the URL through users instead of projects does sound like a good approach, and you could still utilize the API endpoint for JQL search option and use a "worklogauthor" constricted in a date range via "worklogdate", something like this:

project = EXAMPLE and worklogAuthor = "testUser" and worklogDate >= startofday('date') AND worklogDate <= endofday('date')

And then within your script to format the URL, you could iterate the author and the worklogdate "startofday('$date')" and "endofday('$date')" value on a date variable on a value of NULL for today, -1d for yesterday, -2d for the day before and so on to capture the intended range for a cycling range, for example, to capture the last 7 days each time the query is run.  Or you could enter the variable as exact dates in a format like the following:

  • $date = "YYYY/MM/DD"

and loop with variables on the username and date range as variables.

Additionally, I discussed a similar topic with another user in the THIS THREAD that points to a few other threads that touch on some related options a bit more and has some really good info, particularly the one that has the noted github repo containing a time-tracking per user script that would be a really good reference point to get started and pull from,  And I am just reposting that section of the discussion below as a reference:

There is a really good example on how to do this on a per-user basis from the API with example scripts linked via GitHub repo in the following community post, which looks like it lines up with what you are going for, and would be a really good starting point to pull and collate the data set:

There are some more discussions in the following threads on this approach with some more examples as well if you wanted to go this route:

Hope this helps get you pointed in the right direction.

Regards,
Earl

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events