2

I'm trying to integrate a web app in PHP to integrate Xero. My objective is to submit a leave form to Xero from the application.

I'm using https://github.com/XeroAPI/XeroOAuth-PHP and did manage to get the employee lists. But the example request shows I need to pass the LeaveTypeID along with the EmployeeID. Where can I get the LeaveTypeIDs ie. What is the Leave type ID for Annual Leave or Sick leave. Here is the Sample xml Request I found in the example in http://developer.xero.com/documentation/payroll-api/leaveapplications/

<LeaveApplications>
    <LeaveApplication>
        <EmployeeID>5abad362-28aa-4c2c-a9cb-0899f7262d62</EmployeeID>
        <LeaveTypeID>dc182d9a-a270-4f4e-acd7-af702d5a4382</LeaveTypeID>
        <Title>My Test Leave</Title>
        <StartDate>2013-04-11</StartDate>
        <EndDate>2013-04-11</EndDate>
    </LeaveApplication>
</LeaveApplications>

I searched the Internet, Xero documentation and the community portal but nothing is there> Any help is much appreciated.


Updates:

@ronanq - I've Tried that, using the following code to get the LeaveTypes from the Demo account

$response = $XeroOAuth->request('GET', $XeroOAuth->url('PayItems', 'payroll'));
pr($response); exit;

getting the following response:

code => 401
response => You do not have permission to access this resource.

The other end points are working fine.


Solution: Thanks to @ronanq. the "payroll.payitems" needed to be added as a scope on Authorization. That will give access to get the LeaveTypes from xero

Tanvir Gaus
  • 205
  • 1
  • 3
  • 10

1 Answers1

4

You can retrieve leave types and their associated LeaveTypeIDs from the PayItems endpoint.

ronanq
  • 116
  • 2
  • Thanks, will check it tomorrow. meanwhile i have another problem with the code from [link](https://github.com/XeroAPI/XeroOAuth-PHP) - The public example takes me to Authorize the app every time the token expires. how can I renew the token if someone already has authorized the app without sending him to authorize it again? – Tanvir Gaus Oct 25 '15 at 10:08