How do I create multiple worklogs at once using JIRA Tempo API?

chrisjacks March 24, 2021

Using the API, I can successfuly create a single Tempo worklog entry with...

{
"attributes": {
"_Activity_": {
"name": "Activity",
"workAttributeId": 1,
"value": "Research"
}
},
"billableSeconds": null,
"comment": null,
"remainingEstimate": null,
"originTaskId": "PROJECTX-2",
"timeSpentSeconds": 10944,
"worker": "janedoe",
"started": "2021-03-22",
"endDate": "2021-03-26T00:00:00.000"
}

However if I try to create a bunch at once using an array like this...

[
{
"attributes": {
"_Activity_": {
"name": "Activity",
"workAttributeId": 1,
"value": "Research"
}
},
"billableSeconds": null,
"comment": null,
"remainingEstimate": null,
"originTaskId": "PROJECTX-2",
"timeSpentSeconds": 10944,
"worker": "janedoe",
"started": "2021-03-22",
"endDate": "2021-03-26T00:00:00.000"
},
{
"attributes": {
"_Activity_": {
"name": "Activity",
"workAttributeId": 1,
"value": "Development"
}
},
"billableSeconds": null,
"comment": null,
"remainingEstimate": null,
"originTaskId": "PROJECTX-1",
"timeSpentSeconds": 13680,
"worker": "janedoe",
"started": "2021-03-22",
"endDate": "2021-03-26T00:00:00.000"
},
{
"attributes": {
"_Activity_": {
"name": "Activity",
"workAttributeId": 1,
"value": "Admin Work"
}
},
"billableSeconds": null,
"comment": null,
"remainingEstimate": null,
"originTaskId": "PROJECTX-3",
"timeSpentSeconds": 2736,
"worker": "janedoe",
"started": "2021-03-22",
"endDate": "2021-03-26T00:00:00.000"
}
]

...I get the following error: 

Can not deserialize instance of com.tempoplugin.worklog.v4.rest.TimesheetWorklogBean out of START_ARRAY token at [Source: org.apache.catalina.connector.CoyoteInputStream@37059e8a; line: 1, column: 1]

My JSON is valid according to both my own JSON parsing tools and double-check with online tools like https://jsonlint.com/.  NB: this code block strips indenting spaces.
And I know this used to work, but perhaps I am thinking about an older version of JIRA Server.

Does anyone have any clues as to what might be causing this error?

1 answer

1 accepted

1 vote
Answer accepted
Alexander Eck [Tempo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2021

HI @chrisjacks ,

our REST API do not support batch uploading. You will need to call the POST endpoint for each single worklog that you want to create.

Feel free to submit an enhance request for that in our idea portal.

BR

chrisjacks March 24, 2021

OK thanks, good to have that confirmed. :)

Suggest an answer

Log in or Sign up to answer