1

I have tested my post data with the Xero API Previewer feature and successfully submitted leave. Similar to the following (ID's are different):

<LeaveApplication>
<EmployeeID>9f8f9336-4a24-4309-8498-d7de6fd10ef3</EmployeeID>
<LeaveTypeID>e7c26052-46d9-4611-85b7-850eb3041d82</LeaveTypeID>
<Title>Seth Test Leave</Title>
<StartDate>2019-01-13T00:00:00</StartDate>
<EndDate>2019-01-18T00:00:00</EndDate>
</LeaveApplication>

I am using the following python code in a Jupyter notebook:

data = {'EmployeeID': '9f8f9336-4a24-4309-8498-d7de6fd10ef3', 
        'LeaveTypeID': 'e7c26052-46d9-4611-85b7-850eb3041d82', 
        'Title': 'Annual Leave', 
        'StartDate': datetime(2019, 1, 14), 
        'EndDate': datetime(2019, 1, 14)}

xero.payrollAPI.leaveapplications.save_or_put(data)

I get the following output to the console, but no indication that the leave has been submitted when I review the leave applications through the Xero portal online.

('https://api.xero.com/payroll.xro/1.0/LeaveApplications', 
{}, 
'post', 
{'xml': b'<EmployeeID>9f8f9336-4a24-4309-8498-d7de6fd10ef3</EmployeeID>
            <LeaveTypeID>e7c26052-46d9-4611-85b7-850eb3041d82</LeaveTypeID>
            <Title>Annual Leave</Title>
            <StartDate>2019-01-14T00:00:00</StartDate>
            <EndDate>2019-01-14T00:00:00</EndDate>'}, 
None, 
False)

Whereas my POST works with the Xero API Previewer and can be seen in the Xero portal. Further, when reviewing the history in the API previewer I see that it is a "GET" and not a "POST". I was under the impression that a "save_or_put" would do a POST and update an existing entry or create a new entry. Any suggestions on why it is not a post?

Seth
  • 8,213
  • 14
  • 71
  • 103

0 Answers0