[TIME-269] RESTful timesheet endpoint

Issue #269 resolved
Andriy Zhdanov repo owner created an issue

Suggested by Andrey Ognevsky on 2012/6/28

Какое-то API (желательно REST, конечно же, но сойдет любое другое), чтобы собрать кол-во отработанных часов для конкретного пользователя.

Можно ли получить извне (зная, понятное дело, все логины/пароли) свою статистику по часам за выбранный период времени?

In english: API better REST endpoint to get sum of worked time for particular person in a selected period of time.

By azhdanov/Andrew Zhdanov on Wed, 11 Jul 2012 02:17:08 -0700

Comments (35)

  1. Andriy Zhdanov reporter

    With the following url /rest/timesheet-gadget/1.0/raw-timesheet.json it is now possible to get raw Timesheet data as json (or xml if end with .xml) in the following format, e.g.:

    { "worklog" : [ { "entries" : [ { "author" : "admin", "authorFullName" : "admin", "comment" : "test", "created" : 1340870920388, "startDate" : 1340870880000, "timeSpent" : 3600, "updateAuthor" : "admin", "updateAuthorFullName" : "admin", "updated" : 1340870920388 } ], "key" : "TP-1", "summary" : "Some Problem" } ] }

    It accepts the following parameters targetUser - optional userId, targetGroup - optional group name, e.g. jira-users, startDate - optional begin date in Jira date picker format, e.g. 01/Jun/2012, endDate - optional end date, projectid - optional, filterid - optional.

    If nothing is specified it behaves like report, displays data a week before current day for currently logged in user.

    Dates in response are UNIX time - milliseconds since 01/01/1970; timesSpent is in seconds.

    Let me know your suggestions for improvements in comments or in new requests with this one as a parent.

    By azhdanov on Wed, 11 Jul 2012 02:43:13 -0700

  2. Robert Egginton

    Note that at present, in the parameters for the REST requests, the projectId must actually have a lower-case i: projectid.

  3. sagar_patil_

    Hi Andriy,

    I dont have the add on installed.
    let me explain you what i have done. My req is to download all the jira issues and jira time sheet. I am done with downloading the jira issues using JIRA rest api url (https://jira.atlassian.com/rest/api/latest/search?jql=project=JRA) and i have implemented this using .net application(Code) where i have sent in api url through httprequest and got the httpresponse in json format. if i am not wrong then i have to do the same thing for downloading jira timesheet but i am not able find the JIRA rest api url for timesheet. Could you please let me know if you have any other idea to download the jira timesheet through coding? sample code will be helpful.

    Thanks,
    Sagar Patil.

  4. Andriy Zhdanov reporter

    Please see first comment in this issue, there is full description what's supported, in short you can pass projectid in url.

  5. Andriy Zhdanov reporter

    Hi Sagar,

    Problem is that you need project ID, like 10001, not KEY. And no jql, just timesheet.json?projectid=10001&....

    Thank you.

  6. sagar_patil_

    Hi Andriy,

    Thank you so much for the help.

    The way you said to create the URL is worked form me i.e just timesheet.json?projectid=10001&...
    now I am able to get the jira timesheet with all the details but I am not able to interpret the dates those are there in the json reply "created" : 1340870920388, "startDate" : 1340870880000 . I know that "Dates in response are UNIX time - milliseconds since 01/01/1970; timesSpent is in seconds" but I want them to convert to some proper date format like "2013/10/17". Could you please help me how I can get them in proper Date format?

  7. Andriy Zhdanov reporter

    Hi Sagar,

    There is no way to specify or change format in the response JSON, but there are plenty of ways to convert UNIX time to Date, depending on technology you use. Please find and chose one the most appropriate for you.

    Thank you.

  8. Richard Mordinyi

    Hi there,

    when I call the rest API (using FF Addon RestEasy) without any parameters, it returns a result set similiar to the results of the jira dashboard gadget. however, when I add the parameter "targetGroup" with "jira-developers" as value the result set remains the same, while the table in the gadget changes. what am i doing wrong? thx!

  9. Andriy Zhdanov reporter

    Hi Richard,

    Looks like it's some kind of bug in RestEasy. It looks like it caches request - try reloading RestEasy tab, and do first request with the parameter.

    I've checked with FireBug and I can see that changing parameters after first request does not make effect.

    Thank you.

  10. Andrii Iegorov

    Note that at present, in the parameters for the REST requests, the filterId must actually have a lower-case i: filterid.

    It seems that it is not sufficient to specify only filterid. You have to specify targetUser or targetGroup at least in order to get non-empty response.

  11. Andriy Zhdanov reporter

    Right, fixed doc, thank you for noticing.

    Regarding targetUser or targetGroup, this is because it falls back to currently logged in user, i.e. to one you use to authenticate rest call.

  12. Konstantin Laskovenko

    Hi Andriy

    I do not know if it the right place to submit my feature request.

    We are integrating Jira and our corporate time management system. Your REST interface does fit our needs perfectly. The only thing is missing: filtering by updated field. We want to fetch only worklog records created/modified within certain period of time. I know it can be done on the issues level but it is not exactly what we need. Can you provide two additional parameters updatedBefore and updateAfter?

  13. Jaganathan M

    Hi,

    In the JSON response timeSpent value, am getting delete work log value as well. So is there any way i can able to get the timeSpent without deleted work log time?

    Thanks

  14. Jaganathan M

    Hi Andriy,

    Thanks for your response. Below is the example

    Worklog for 2nd Aug 2016 to JIRA-XXX

    1st i have added 2 hours work log.
    but i have deleted that 2 hours and
    agin added 4 hours to same jira for same date

    So in ths scenario am getting 4 hours in timespent value for this date for same JIRA ID.

    Please help me to resolve this issue.

    Thanks

  15. Jaganathan M

    In Jira am getting only 4 hours.

    And one more clarification, in my target group i have N no of users with different time zone. So which time zone i need to use while convertting the startDate value?

  16. Log in to comment