Saturday 11 April 2015

Xero Payroll API

Xero - Payroll API access not authorised

I recently ran into an issue when trying to use the Xero Payroll API. My company, which is comprised of many franchises, was in the process of moving away from MYOB and preparing to go live with Xero. Each franchise in our organisation needed to be set up as a new application. We followed the documentation available to us and undertook the steps outlined below;
  1. Created public/private key pairs for each franchise using openSSL http://developer.xero.com/documentation/advanced-docs/public-private-keypair/
  2. Setup a new private application for each franchise
  3. Uploaded the cer file just created with the openSSL commands
  4. Ensured that the checkbox 'Enable Payroll API for this organisation' was ticked
However each time we tried a call to the Payroll API Previewer (on the Xero site) using any of the payroll endpoints we consistently got this error message 'Payroll API access not authorised'.

A lot of time and research was invested to figure out the issue and in the end the solution was so simple. We discovered by chance that by logging into each organisations Xero, selecting Settings and then Payroll Setting was enough to get Xero to recognise the payroll API. This was done for every franchise and the payroll API for all started to work immediately.