With a bit of tinkering I found the issue is that the XML is meant to be PayItems (plural), instead of PayItem (singular).
<PayItems>
...
</PayItems>
It appears the issue is that the PayItems resource is different to all the other Xero resources, in that it is made up of the following:
EarningsRates
DeductionTypes
ReimbursementTypes
LeaveTypes
But the XML parser the xero module is expecting the resource is the root element of the XML (this is correct but plural) and that the root array is the singular form of the resource.
I've managed a workaround by editing the following line in the index.js file.
From
post_body = new EasyXml({rootElement: inflect.singularize(root), rootArray: root, manifest: true}).render(body);
To
if (path.search('PayItems') !== -1) {
post_body = new EasyXml({rootElement: root, rootArray: root, manifest: true}).render(body);
} else {
post_body = new EasyXml({rootElement: inflect.singularize(root), rootArray: root, manifest: true}).render(body);
}
Please let me know your thoughts on this issue, I'm sure there's a better solution to the problem.
-Gary
Hi,
I've had issues with issuing POST requests for sending new Earnings Rates to Xero.
When creating the JSON for sending with the POST request.
When supplied to
xero.call('POST', 'payroll', '/PayItems', newEarnings, function(...
In the index.js file for the xero module, the newEarnings variable is parsed into XML, this is shown below.
The response from Xero is
With a bit of tinkering I found the issue is that the XML is meant to be PayItems (plural), instead of PayItem (singular).
It appears the issue is that the PayItems resource is different to all the other Xero resources, in that it is made up of the following:
But the XML parser the xero module is expecting the resource is the root element of the XML (this is correct but plural) and that the root array is the singular form of the resource.
I've managed a workaround by editing the following line in the index.js file.
From
post_body = new EasyXml({rootElement: inflect.singularize(root), rootArray: root, manifest: true}).render(body);
To
Please let me know your thoughts on this issue, I'm sure there's a better solution to the problem. -Gary