Hello,
Recently I've been implementing some automation that require some Tempo data, and to achieve my goals I'd need to retrieve all the planned items for a specific Tempo Team.
For now I've not been successful as it seems that the queries I've tried all return empty results.
I've tried multiple options based on the tempo planner allocation endpoint:
https://www.tempo.io/server-api-documentation/planner?hsLang=en#tag/Allocation
I've tried this call with the assigneeType as "team", but doesn't matter what I fill on the assigneeKeys field I always get an empty response,
As I understand it, this should have the team ID from the team I'm trying to retrieve data from, I've tried both the ID numeric value as well as the team name but I haven't got any response.
Is what I'm trying to do even possible? If it is I'd like to know what I'm getting wrong here.
Hi @Contact IT
I have done this by using the Tempo Team custom field on a ticket. The data is extracted in a workflow post function and attached to the ticket.
These are my functions for getting team info. They are located in a class saved in the Script Editor scriptrunner data.
called as
int teamParam = ExtractWorklogUtils.getTeamId
((String)team, baseUrl, TempoConstants.CREDENTIALS)
static
int
getTeamId(String teamName, String baseUrl, String credentials) {
RESTClient restClient
HttpResponseDecorator response
int
retval =
0
try
{
restClient =
new
RESTClient(baseUrl)
restClient.encoderRegistry =
new
EncoderRegistry(charset:
'UTF-8'
)
restClient.setHeaders([
Authorization :
"Basic ${credentials.bytes.encodeBase64()}"
,
"X-Atlassian-Token"
:
"no-check"
,
Accept:
"*/*"
,
"Content-Type"
:
"application/json"
])
response = restClient.
get
(path:
'/rest/tempo-teams/2/team'
, contentType: ContentType.JSON )
if
(response) {
switch
(response.status) {
case
200
:
response.data.
each
() {
if
(it.name.equals(teamName)) {
retval = it.id
}
}
default
:
logit.info
"Whats this ${response.status}"
}
}
}
catch
(Exception e) {
logit.info e.getMessage()
}
return
retval
}
static
ArrayList getTeamMembers(
int
teamId, String baseUrl) {
RESTClient restClient
HttpResponseDecorator response
ArrayList retval =
new
ArrayList()
try
{
restClient =
new
RESTClient(baseUrl)
restClient.encoderRegistry =
new
EncoderRegistry(charset:
'UTF-8'
)
restClient.setHeaders([
Authorization :
"Basic ${TempoConstants.CREDENTIALS.bytes.encodeBase64()}"
,
"X-Atlassian-Token"
:
"no-check"
,
Accept:
"*/*"
,
"Content-Type"
:
"application/json"
])
response = restClient.
get
(path:
'/rest/tempo-teams/2/team/'
+teamId+
'/member'
, contentType: ContentType.JSON )
}
catch
(Exception e) {
logit.info
"Error : ${e.getMessage()}"
logit.info
"Message : ${e.response.data}"
logit.info
"Reason. : ${e.response.getStatusLine().getReasonPhrase()}"
logit.info e.getMessage()
}
if
(response) {
switch
(response.status) {
case
200
:
logit.info
"Process :-"
def
jdata = groovy.json.JsonOutput.toJson(response.data)
def
json =
new
JsonSlurper().parseText(jdata)
json.
each
() {
retval.add(it.member.name)
}
}
return
retval
}
}
The teamid is added to a json body
StringBuffer jsonBody =
new
StringBuffer()
jsonBody.
append
(
"{"
)
jsonBody.
append
(
'"from":"'
+ startParam +
'"'
)
if
(end) {
jsonBody.
append
(
', "to":"'
+ endParam +
'"'
)
}
if
(team) {
jsonBody.
append
(
',"teamId":['
+ teamParam +
']'
)
}
jsonBody.
append
(
"}"
)
This search call is like this
RESTClient restClient
HttpResponseDecorator response
try
{
restClient =
new
RESTClient(baseUrl)
restClient.encoderRegistry =
new
EncoderRegistry(charset:
'UTF-8'
)
restClient.setHeaders([
Authorization :
"Basic ${TempoConstants.CREDENTIALS.bytes.encodeBase64()}"
,
"X-Atlassian-Token"
:
"no-check"
,
Accept:
"*/*"
,
"Content-Type"
:
"application/json"
])
response = restClient.post(path:
'/rest/tempo-timesheets/4/worklogs/search'
, contentType: ContentType.JSON, body:
"${jsonBody.toString()}"
)
logit.info response
logit.info
"Status : ${response.status}"
logit.info
"Body : ${response.data.text}"
}
catch
(Exception e) {
logit.info
"Error : ${e.getMessage()}"
logit.info
"Message : ${e.response.data}"
logit.info
"Reason. : ${e.response.getStatusLine().getReasonPhrase()}"
logit.info e.getMessage()
commentBody.
append
"|Response Error | ${e.statusCode}|\n"
commentBody.
append
"|Message | ${e.response.data}|\n"
commentBody.
append
"|Reason | ${e.response.getStatusLine()}|\n"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.