1

I'm using the Payroll - NZ Xero API. I'm wondering if there is a way to post multiple timesheet lines at once.

My application sends large batches of timesheets in one hit. Going by the docs, I should send each timesheet line individually. This works fine, but it's very feasible to hit the rate limit of 60 requests per minute. It's not exactly efficient to send hundreds of timesheet lines in seperate requests.

I have attempted to send an array to the /timesheets/{TimesheetID}/lines, but I the following error...

{ "status": 400, "detail": "BadRequest", "invalidFields": [ { "name": "Date", "reason": "Date is required" }, { "name": "EarningsRateID", "reason": "The earnings rate is required" }, { "name": "Time", "reason": "Time must be greater than zero" } ] }

...which implies to me an array is not being handled. I've also tried posting a timesheet (/timesheets) with an included TimesheetLines array, but the lines are discarded.

Am I missing something, or is this a feature that the Payroll API doesn't currently offer?

Devman
  • 310
  • 2
  • 10
  • I was wondering if you ever got a definitive answer on this? Thanks... – nzbenny Apr 06 '20 at 03:22
  • No, never got any actual answer. However it appears that posting to the `/timesheets` route with a `TimesheetLines` array now works. Not sure about posting an array to the `/timesheets/{TimesheetID}/lines` route. – Devman Apr 07 '20 at 02:58
  • Thanks for that info @Devman - uploading the lines would at least solve part of the problem... Are you able to provide any further details on the endpoint and array format you are posting to the `/timesheets` route? do you need `/Timesheets/{ID}`, or should it just be in the array? Or do you mean load the lines array as an array within the timesheet itself - I have tried so many ways, but get various 400/405 back.... Many thanks once again! – nzbenny Apr 08 '20 at 10:00
  • I think it just works when you post a new timesheet. You can include a TimesheetLines array that is in the same format as it would be in the GET method (minus the IDs of course). https://developer.xero.com/documentation/payroll-api-nz/timesheets – Devman Apr 09 '20 at 22:56

0 Answers0