Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

GetWorklog API call not working today April Fools Joke

We have the following code that has been working.   Today it has stopped.

 

Getting a 404 Not Found Error

 

Any help would be appreciated.   

 

 domainAddress = "https://app.tempo.io/api/1/getWorklog"
   
    apiOptions = "&baseUrl=https://company-agile.atlassian.net&format=xml&diffOnly=false&addBillingInfo=true&addIssueDetails=true&addUserDetails=true&addWorklogDetails=true&addIssueDescription=true&addIssueSummary=true&tempoApiToken=supersecretAPI"

 

timeSheetURL = domainAddress & "?dateFrom=" & Format(startDate, "yyyy-mm-dd") & "&dateTo=" & Format(midDate, "yyyy-mm-dd") & apiOptions
        Application.StatusBar = "Downloading Timesheet Data " & Format(startDate, "yyyy-mm-dd") & " To " & Format(midDate, "yyyy-mm-dd") & "..."
        DoEvents
        xmlDoc.Load (timeSheetURL)
   

3 answers

1 accepted

0 votes
Answer accepted

This is how I ended up doing it. Looping through all the tempo entries saving the data I need from each row in an array, then doing a jira api search with all the tasks to get the account information which I store in a map. Converting the rest of the code after that was trivial.

 

$worklogs = array(); // All data from tempo worklog api
$accountDetails = array(); // Key = task, value = account information
$url = "https://api.tempo.io/core/3/worklogs?from=" . $start . "&to=" . $end . "&limit=1000";
while (true){
$response = Unirest\Request::get($url,$headers);
if($response->code > 204){
print "ERROR: ";
print $url;
return;
}
$result=$response->body->results;
$tasklist = "";
foreach ($result as $row){
$task = $row->issue->key;
if(!isset($accountDetails[$task])) {
$accountDetails[$task] = "pending";
$tasklist .= "$task,";
}
$worklogs = saveRequiredFields($worklogs, $row);
}
// Now get account info from Jira
$tasklist = rtrim($tasklist, ','); // Remove final ','

$jurl = "https://teknique.jira.com/rest/api/3/search";
Unirest\Request::auth($login, $apikey);

$startAt = 0;
while (true){
$custombody = str_replace("XXXXX", "$tasklist", $jbody);
$custombody = str_replace("STARTAT", "$startAt", $custombody);
$jresponse = Unirest\Request::post($jurl, $jheaders, str_replace("XXXXX", "$tasklist", $custombody));
$jresult = $jresponse->body;
if(sizeof($jresult->issues) == 0) break;
foreach ($jresult->issues as $row){
$fields = array();

// Save the account info I need in a map
$fields["project_name"] = $row->fields->project->name;
$fields["id"] = $row->fields->customfield_11810->id;
$fields["account_id"] = $row->fields->customfield_11810->id;
$fields["name"] = $row->fields->customfield_11810->properties->name;
$fields["project_key"] = $row->fields->project->key;
$fields["categoryname"] = $row->fields->customfield_11810->properties->category->name;
$fields["category"] = $row->fields->customfield_11810->properties->category->name;
$fields["category_code"] = $row->fields->customfield_11810->properties->category->key;
$accountDetails[$row->key] = $fields;
}
$startAt+=100;

}

if(!isset($result->next)) break;
$url = $result->next;
}

 

 

 

function saveRequiredFields($worklogs, $result){
  $row = array();
$row["key"] = trim((string) $result->issue->key);
$row["displayName"] = trim((string) $result->author->displayName);
$row["full_name"] = trim((string) $result->author->displayName);
$row["accountId"] = $result->author->accountId;
$row["userAccountId"] = $result->author->accountId;
$row["startDate"] = $result->startDate;
$row["work_date"] = $result->startDate;
$row["hours"] = (float) ($result->timeSpentSeconds / 3600);

 

array_push($worklogs, $row);
return $worklogs;
}

Awesome Tim,

and thanks for sharing the code to the community. It is much appreciated!

Happy Easter and stay safe!

Hi Ken,

Today we decommissioned the Servlet API in order to align with Atlassian's security requirements for Cloud applications.  This change was originally announced early 2019, and we have done our best to communicate this to our customers with several announcements since then, as well as reaching out directly via email to our contacts.

I'm very sorry if this has caught you by surprise. Here is our lates announcement which includes links to documentation and knowledge base articles about how to transition to using the more secure REST API.

https://tempo-io.atlassian.net/wiki/spaces/CLOUDNEWS/pages/763691139/2020-04-01+Tempo+has+Decommissioned+the+Servlet+API

I recommend watching the Tempo Cloud announcement page to get notification when we make important changes to our cloud products. 

https://tempo-io.atlassian.net/wiki/spaces/CLOUDNEWS/pages/242942398/Tempo%2BCloud%2BAnnouncements

Kind regards,

Hlynur Johnsen

Group Product Manager - Tempo for Jira 

I was also taken by surprise by this yesterday. And now to my dismay, it looks like the REST API can not provide the information that is essential to my reporting.

 

I HAVE to get the billing category and account code per worklog but it does not look like that is possible. This is a biiiig problem for me!

 

Please tell me there is a workaround

 

Tim

We are in the same boat.   Billing information associated to the Tempo time.  Not sure how to get it.

Hello,

please refer to this article on the alternative REST endpoints to use instead.

Thanks and regards

Thanks.

 

I have read that article and still don't have a clear idea on how to get the billing and user data.

Hi Ken,

  1. The user properties are available from the Jira API .
  2. The account information is NOT returned from the worklog REST API. But there is an endpoint to get all worklogs tight to an account (https://api.tempo.io/core/3/worklogs/account/{accountKey})

Hope that helps

Please confirm my understanding:

 

I have to retrieve the worklogs I want and then query the Jira API with each task from that list to get the account information?

 

Is that correct?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

290 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you