library = pyxero 0.9.1
Hey there,
I'm trying to automate the uploading of timesheets to Xero using Python but have hit a stumbling block. I have no issue retrieving information using API but when I try to POST a new timesheet I get a 405 response code. I've tried to simplify my JSON data to the bare minimum Xero allows, but the error still persists. Sample code below
from xero import Xero
import configs
import datetime
from xero.auth import PrivateCredentials
credentials = PrivateCredentials(configss.key, configss.RSAstr)
xero = Xero(credentials)
employees = xero.payrollAPI.employees.all()
timesheets = {'timesheets': {'timesheet': {'EmployeeID': employees[0]["EmployeeID"],
'StartDate': datetime.datetime(2018,8,15),
'EndDate': datetime.datetime(2018,8,21),
'Status': 'Draft'}}}
xero.payrollAPI.timesheets.put(timesheets)
Please note that I can post new contacts and invoices without a problem. Looking at my API call history from the app.xero.com site I see a message with
Request Message =
<Timesheets><Timesheet><EmployeeID>38fcaf73-e35c-4f38-9ebe-642ef6d5b7c7</EmployeeID>
<StartDate>2018-09-15</StartDate><EndDate>2018-09-21</EndDate>
<Status>DRAFT</Status></Timesheet></Timesheets>
Response 405 - Method not allowed