xero-php
xero-php copied to clipboard
rawurlencode() expects parameter 1 to be string
When using:
$xero->loadByGUIDs(Invoice::class, $ids);
Where $ids is an array of invoice numbers...
You get the error:
rawurlencode() expects parameter 1 to be string, array given in /vendor/calcinai/xero-php/src/XeroPHP/Helpers.php on line 209
Any idea how to solve this?
@DeweyOx are you certain that $ids
isn't an array of arrays?
Yes. Just debugged it:
array(5) {
[0] => '1181'
[1] => 'INV-0027'
[2] => 'INV-0028'
[3] => '1171'
[4] => 'SI-2'
}
If i use '@' to suppress warnings, it works. But I can't be using that on production.
@DeweyOx Just checked out the Xero docs, they expect a comma-separated string of ids...
IDs, InvoiceNumbers, ContactIDs, Statuses | Filter by a comma-separated list of InvoicesIDs, InvoiceNumbers, ContactIDs or Statuses.
The library should probably be smart enough to implode these for you...
it was the first thing I tried, but it fails with this lib. Any workarounds?
What does it do, I assume you're doing something like this?
$xero->loadByGUIDs(Invoice::class, implode(',', $ids);
exactly, but I get:
array(2) { 'success' → bool:false 'msg' → str(11) 'Bad Request' }
I changed Request.php to read:
public function setParameter($key, $value) { if(is_array($value)) { $value = implode(',', $value); } $this->parameters[$key] = $value; return $this; }
but I get the same Bad Request