-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
SDK you're using (please complete the following information):
- Version 6.0.0
Describe the bug
When testing upgrading to SDK version 6, I am getting unhandled InvalidArgumentException fatal errors when running getContacts().
The issue only occurs if the contact being looked up does not existing in Xero. If the contact does exist in Xero, no exception is thrown.
Full stack trace below:
Uncaught InvalidArgumentException: invalid length for $contacts when calling GetContactsResponse., number of items must be greater than or equal to 1. in /..../app/vendor/xeroapi/xero-php-oauth2/lib/Models/Accounting/GetContactsResponse.php:399
Stack trace:
#0 /..../app/vendor/xeroapi/xero-php-oauth2/lib/AccountingObjectSerializer.php(358): XeroAPI\XeroPHP\Models\Accounting\GetContactsResponse->setContacts(Array)
#1 /..../app/vendor/xeroapi/xero-php-oauth2/lib/Api/AccountingApi.php(28868): XeroAPI\XeroPHP\AccountingObjectSerializer::deserialize(Object(stdClass), '\\XeroAPI\\XeroPH...', Array)
#2 /..../app/vendor/xeroapi/xero-php-oauth2/lib/Api/AccountingApi.php(28811): XeroAPI\XeroPHP\Api\AccountingApi->getContactsWithHttpInfo('38b66c...........', NULL, 'ContactNumber="...', NULL, NULL, 1, true, false, NULL, NULL)
#3 /..../app/wwwroot/includes/pageSections/addressbook/addEdit_form.php(319): XeroAPI\XeroPHP\Api\AccountingApi->getContacts('38b66c..........', NULL, 'ContactNumber="...', NULL, NULL, 1, true)
#4 /..../app/wwwroot/addressbook.php(256): require('/..........')
#5 {main} thrown
To Reproduce
Run the following code to look up a contact in Xero, where the query would ordinarily return zero results:
try {
$xeroApiInstance = new XeroAPI\XeroPHP\Api\AccountingApi(
new GuzzleHttp\Client(),
$xeroApiAuthorisation->getConfig()
);
$resultXeroContact = $xeroApiInstance->getContacts($xeroApiAuthorisation->getTenantId(), null, 'ContactNumber="'.$addressbook_id.'"', null, null, 1, true);
if (!is_null($resultXeroContact) && count($resultXeroContact->getContacts()) == 1) {
///Logic to handle the contact details
}
} catch (\XeroAPI\XeroPHP\ApiException $e) {
if ($e->getCode() != 404) {
//handle the exception
}
}
Expected behavior
A 404 http code should be thrown by XeroAPI\XeroPHP\ApiException in the catch block.
Metadata
Metadata
Assignees
Labels
No labels