You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using BankStatement API to sync bank statements from Xero for a given account ID. It works fine except when there is no content returned from Xero. Please see below my code. The program dies after $request->send().
function xero_get_bank_statements($fromDate,$toDate,$accountID)
{
$url = new URL($xero, 'Reports/BankStatement');
$request = new Request($xero, $url, Request::METHOD_GET);
$request->setParameter('bankAccountID', $accountID);
$request->setParameter('fromDate', $fromDate);
$request->setParameter('toDate', $toDate);
$request->send();
$elements = $request->getResponse()->getElements();
return $elements;
}
I troubleshooted the issue and noticed that send() function first sends data to xero and then creates a response object using $guzzleResponse->getBody()->getContents(). For me, there is nothing returned from Xero. I am guessing there is no statements for that account ID, but I am not sure.
After creating response object, parse() function is called to parse the response. This is where the execution stops. There is no return value or response. I guess parse is failing as there is no content. There is no check for response from xero in parse function. I think we should not allow parsing if there is no content returned from Xero.
The text was updated successfully, but these errors were encountered:
@calcinai No specific reason. The code was written few years back by another developer. I have just inherited it. Thanks for pointing it out though. We will start using it for upcoming features. But will that solve the problem that I reported?
Thank you.
I am using BankStatement API to sync bank statements from Xero for a given account ID. It works fine except when there is no content returned from Xero. Please see below my code. The program dies after $request->send().
function xero_get_bank_statements($fromDate,$toDate,$accountID)
{
$url = new URL($xero, 'Reports/BankStatement');
$request = new Request($xero, $url, Request::METHOD_GET);
$request->setParameter('bankAccountID', $accountID);
$request->setParameter('fromDate', $fromDate);
$request->setParameter('toDate', $toDate);
$request->send();
$elements = $request->getResponse()->getElements();
return $elements;
}
I troubleshooted the issue and noticed that send() function first sends data to xero and then creates a response object using $guzzleResponse->getBody()->getContents(). For me, there is nothing returned from Xero. I am guessing there is no statements for that account ID, but I am not sure.
After creating response object, parse() function is called to parse the response. This is where the execution stops. There is no return value or response. I guess parse is failing as there is no content. There is no check for response from xero in parse function. I think we should not allow parsing if there is no content returned from Xero.
The text was updated successfully, but these errors were encountered: