Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

sanitizeForSerialization Failing

Started by John Cotton -   in Wrapper libraries

I'm trying to add an invoice.

Here's what my object looks like:

XeroAPI\XeroPHP\Models\Accounting\Invoices Object (
[container:protected] => Array
(
[invoices] => Array
(
[0] => XeroAPI\XeroPHP\Models\Accounting\Invoice Object
(
[container:protected] => Array
(
[type] => ACCPAY
[contact] => f5a77e82-50e3-4340-a6e0-13d6a482a08a
[line_items] => Array
(
[0] => XeroAPI\XeroPHP\Models\Accounting\LineItem Object
(
[container:protected] => Array
(
[line_item_id] =>
[description] => Test Form

[quantity] => 1
[unit_amount] => 60
[item_code] => CGF
[account_code] => 310
[tax_type] => OUTPUT
[tax_amount] =>
[line_amount] =>
[tracking] =>
[discount_rate] =>
[discount_amount] =>
[repeating_invoice_id] =>
)
)

)
[date] => 2020-11-18
[due_date] => 2020-11-20
[line_amount_types] => INCLUSIVE
[invoice_number] =>
[reference] =>
[branding_theme_id] =>
[url] =>
[currency_code] =>
[currency_rate] =>
[status] => AUTHORISED
[sent_to_contact] =>
[expected_payment_date] =>
[planned_payment_date] =>
[cis_deduction] =>
[sub_total] =>
[total_tax] =>
[total] =>
[total_discount] =>
[invoice_id] =>
[repeating_invoice_id] =>
[has_attachments] =>
[is_discounted] =>
[payments] =>
[prepayments] =>
[overpayments] =>
[amount_due] =>
[amount_paid] =>
[fully_paid_on_date] =>
[amount_credited] =>
[updated_date_utc] =>
[credit_notes] =>
[attachments] =>
[has_errors] =>
[status_attribute_string] =>
[validation_errors] =>
[warnings] =>
)
)
)
)
)



But AccountingObjectSerializer::sanitizeForSerialization($_tempBody) is failing silently for that object.

Where am I going wrong?
Hi John. Based on the data provided its hard to see your issue.

Id recommend first looking at the sample code for the PHP sample app: https://github.com/XeroAPI/xero-php-oauth2-app

Looks like you can emulate this function:
https://github.com/XeroAPI/xero-php-oauth2-app/blob/7a6e4240a24f192d25864ca8ef5ca1573a2a3094/example.php#L1384

Or if you are still stuck and think it might be an SDK bug rather than formatting issue you can open a github issue in the SDK itself: https://github.com/XeroAPI/xero-php-oauth2-app

Last option that is always there is to open a support ticket with our API tech support staff by emailing (api@xero.com) however please ensure you have included your apps' client ID, date of specific log, and any other relevant data to ensure our team doesn't spin their wheels.

Best of luck :) let us know if you sort it out!
 

Christopher Knight (Xero Staff)  

Hi Christopher

Thanks for the reply.

It turned out to be bad data in the call. A Line item, left over from an previous integration, was a pure array rather than an object.

It would nice if the serializer threw an error for that kind of thing, rather than fail silently.

Regards
John

 

John Cotton  

Yes it definitely would. If you are able to document with an issue and relevant steps to reproduce in the github SDK we can get that into a future release.
 

Christopher Knight (Xero Staff)