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)
staticintgetTeamId(String teamName, String baseUrl, String credentials) {RESTClient restClientHttpResponseDecorator responseintretval =0try{restClient =newRESTClient(baseUrl)restClient.encoderRegistry =newEncoderRegistry(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) {case200: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()}returnretval}staticArrayList getTeamMembers(intteamId, String baseUrl) {RESTClient restClientHttpResponseDecorator responseArrayList retval =newArrayList()try{restClient =newRESTClient(baseUrl)restClient.encoderRegistry =newEncoderRegistry(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) {case200:logit.info"Process :-"defjdata = groovy.json.JsonOutput.toJson(response.data)defjson =newJsonSlurper().parseText(jdata)json.each() {retval.add(it.member.name)}
}returnretval}
}
The teamid is added to a json body
StringBuffer jsonBody =newStringBuffer()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 restClientHttpResponseDecorator responsetry{restClient =newRESTClient(baseUrl)restClient.encoderRegistry =newEncoderRegistry(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 responselogit.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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.