REST API Integrations
You can use REST API integrations in Timesheet Reports & Gadgets for Jira Server and Data Center.
RESTful Endpoint
Jira has native support for loading worklogs via REST by searching for issues using JQL and including the worklog
field in the fields
request param. For more information, see the Jira documentation.
There are three JQL clauses to limit results set to issues that have relevant worklogs: worklogAuthor
, worklogComment
, and worlkogDate
. See Advanced Searching - Fields reference.
For worklogDate
, valid formats include: 'YYYY/MM/DD'
, 'YYYY-MM-DD'
, or a period format, such as '-5d'
, '4w 2d'
, or date function, such as endOfDay()
for Today
.
For worklogAuthor
, username or membersOf()
can be used.
A request such as the following:
GET /rest/api/2/search?fields=*all&jql=filter=10001 and worklogDate > '2016-03-01' and worklogDate < endOfDay() and worklogAuthor in membersOf("jira-developers")
Yields this JSON response:
{ "expand" : "schema,names",
"issues" : [{ "expand" : "editmeta,renderedFields,transitions,changelog,operations",
"fields" : { "worklog" : { "maxResults" : 2,
"startAt" : 0,
"total" : 2,
"worklogs" : [ { "author" : { "active" : true,
"avatarUrls" : { "16x16" : "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10142",
"48x48" : "http://localhost:2990/jira/secure/useravatar?avatarId=10142"
},
"displayName" : "admin",
"emailAddress" : "admin@example.com",
"name" : "admin",
"self" : "http://localhost:2990/jira/rest/api/2/user?username=admin"
},
"comment" : "test",
"created" : "2013-10-16T17:56:32.887+0200",
"id" : "10012",
"self" : "http://localhost:2990/jira/rest/api/2/issue/10001/worklog/10012",
"started" : "2013-10-19T00:00:00.000+0200",
"timeSpent" : "1h",
"timeSpentSeconds" : 3600,
"updateAuthor" : { "active" : true,
"avatarUrls" : { "16x16" : "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10142",
"48x48" : "http://localhost:2990/jira/secure/useravatar?avatarId=10142"
},
"displayName" : "admin",
"emailAddress" : "admin@example.com",
"name" : "admin",
"self" : "http://localhost:2990/jira/rest/api/2/user?username=admin"
},
"updated" : "2013-10-16T17:56:32.887+0200"
},
{ "author" : { "active" : true,
"avatarUrls" : { "16x16" : "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10142",
"48x48" : "http://localhost:2990/jira/secure/useravatar?avatarId=10142"
},
"displayName" : "admin",
"emailAddress" : "admin@example.com",
"name" : "admin",
"self" : "http://localhost:2990/jira/rest/api/2/user?username=admin"
},
"comment" : "test",
"created" : "2013-10-16T17:56:33.075+0200",
"id" : "10013",
"self" : "http://localhost:2990/jira/rest/api/2/issue/10001/worklog/10013",
"started" : "2013-10-14T00:00:00.000+0200",
"timeSpent" : "4h",
"timeSpentSeconds" : 14400,
"updateAuthor" : { "active" : true,
"avatarUrls" : { "16x16" : "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10142",
"48x48" : "http://localhost:2990/jira/secure/useravatar?avatarId=10142"
},
"displayName" : "admin",
"emailAddress" : "admin@example.com",
"name" : "admin",
"self" : "http://localhost:2990/jira/rest/api/2/user?username=admin"
},
"updated" : "2013-10-16T17:56:33.075+0200"
}
]
} },
"id" : "10001",
"key" : "TIME-2",
"self" : "http://localhost:2990/jira/rest/api/2/issue/10001"
}
],
"maxResults" : 50,
"startAt" : 0,
"total" : 1
}
The return contains only the first 20 worklogs per issue, and is not filtered according to the specified worklogDate
and worklogAuthor
queries. It is your responsibility to load all worklogs per issue, using the /rest/api/2/issue/{issueIdOrKey}/worklog endpoint, and filter out worklogs that do not match your criteria. For more help, see this Atlassian Community answer. Alternatively you can use /api/2/worklog for loading large worklogs without issues.
Plugin REST Endpoint
With Timesheet Reports & Gadgets for Jira Server installed, it is possible to get worklogs in json format, including minimum issue data.
For example, with the url /rest/timesheet-gadget/1.0/raw-timesheet.json?moreFields=creator&moreFields=created, the return is:
{
"worklog": [
{
"key": "TIME-1",
"summary": "Hocus Focus Problem",
"entries": [
{
"id": 10014,
"comment": "test",
"timeSpent": 21600,
"author": "admin",
"authorFullName": "admin",
"created": 1458477642089,
"startDate": 1457910000000,
"updateAuthor": "admin",
"updateAuthorFullName": "admin",
"updated": 1458477642089
}
],
"fields": [
{
"label": "2013-03-12T09:45:35+0100",
"value": "created"
},
{
"label": "admin",
"value": "creator"
}
]
}
}
It accepts the following parameters:
targetUser
- optional usernametargetGroup
- optional group name, e.g. jira-usersstartDate
- optional begin date in Jira date picker format, e.g. 01/Jun/2012, or in ISO date format, e.g. 2012-06-01endDate
- optional end date, format is the sameprojectid
- optional, e.g. 10001 (not project key!)filterid
- optionalmoreFields
- optional.
If nothing is specified, it behaves like the report, displaying data a week before the current day for the currently logged in user.
Dates in the response are UNIX time, milliseconds since 01/01/1970
; timesSpent is in seconds.
Export to CSV
You can export raw worklogs in CSV format, similarly to Excel view, by using the CSV View link in the Time Sheet report, or composing the link based on the export link from the Time Sheet, and replacing the htmlExport url parameter with csvExport, for example:
http://localhost:2990/jira/rest/timesheet-gadget/1.0/timesheet.json?csvExport=true&weekends=true&targetUser=admin&showDetails=true&reportingDay=2&groupByField=customfield_group&moreFields=reporter&moreFields=status&moreFields=timespent&moreFields=timetracking&numOfWeeks=1&offset=0&sum=day