To learn more about Tempo products, please visit our Help Center. For support, see our Support Portal.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Current »

Unable to render {include} The included page could not be found.

QuestionHow 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:

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
{"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
{yourJiraurl}/rest/tempo-core/1/work-attribute

For the available values of a worklog attribute check:

REST API
{yourJiraurl}/rest/tempo-core/1/work-attribute/value/{id}

Finally add the cURL command parameters:

cURL 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.

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.


  • No labels