Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Include Page
Tempo for Data Center Header
Tempo for Data Center Header
Eclipse
Page Properties

Question

How can I import worklogs using the Tempo REST API?

Answer

Worklogs can be imported to Tempo using the native Jira csv import functionality. Note that the Jira .csv import does not support worklog attributes. To import worklogs into Tempo with worklog attributes, you will need to use the Tempo REST API and an app like Postman (or the command line). In the example below, we will create an executable script file that can be run on every computer.

1. Create your Excel sheet with the worklogs that you want to import. Your excel sheet should look similar to this:

Image Removed
Image Added

2. The Tempo REST API uses the JSON format to pass the information to Tempo for import. Use Excel to convert the values into a valid JSON format.

JSON payload
Code Block
languagetext
theme
titleJSON payload
{"attributes":
	{
		"_Mileage_":{"value":"15"},
		"_Team_":{"value":"6"},
		"_Billingkey_":{"value":"201433"}
},
	"worker":"taylor",
	"comment":"Import from Tempo API",
	"started":"2018-11-01T09:00:00.000",
	"timeSpentSeconds":7200,
	"originTaskId":"12690"
}

From the payload file above you can see that Tempo needs the correct name of the worklog attribute field and the correct value available. Retrieve available worklog attribute fields by using the following command:

REST API
Code Block
languagetext
titleREST API
{yourJiraurl}/rest/tempo-core/1/work-attribute

For the available values of a worklog attribute check:

REST API
Code Block
languagetext
titleREST API
{yourJiraurl}/rest/tempo-core/1/work-attribute/value/{id}


Finally add the cURL command parameters:

cURL command
Code Block
languagetext
themeEclipsetitlecURL command
curl -D- -u username:password --request POST --url {yourJiraURL}/rest/tempo-timesheets/4/worklogs/ --header 'Content-Type: application/json' --data '{yourJSONpayload}' >> worklog_response.json;

3. Copy the generated cURL command lines from excel and copy them to a text file. Add a "sh" extension to the file and make it executable.

Image Removed
Image Added

Note that the "Value" for "_Billingkey_" in the cURL command in the above screenshot is "accountKey" and not "accountName".

4. Run the script from your terminal by entering "sh {yourscriptfile}.sh". By adding an output file to your cURL commands you can either check the generated worklogs or in case the import failed you will see an error message.