I'm trying to use the REST API in Magento 2 to get orders created after a certain date. But it seems as though everytime I try to use any condition other than "eq", it fails with the following error message:
{
"message": "Notice: Array to string conversion in /var/www/html/magento/vendor/magento/framework/Reflection/TypeCaster.php on line 34",
"trace": "#0 /var/www/html/magento/vendor/magento/framework/Reflection/TypeCaster.php(34): Magento\\Framework\\App\\ErrorHandler->handler(8, 'Array to string...', '/var/www/html/m...', 34, Array)\n#1 /var/www/html/magento/vendor/magento/framework/Reflection/DataObjectProcessor.php(115): Magento\\Framework\\Reflection\\TypeCaster->castValueToType(Array, 'string')\n#2 /var/www/html/magento/vendor/magento/framework/Reflection/DataObjectProcessor.php(107): Magento\\Framework\\Reflection\\DataObjectProcessor->buildOutputDataArray(Object(Magento\\Sales\\Model\\Order\\Payment), '\\Magento\\Sales\\...')\n#3 /var/www/html/magento/vendor/magento/framework/Reflection/DataObjectProcessor.php(113): Magento\\Framework\\Reflection\\DataObjectProcessor->buildOutputDataArray(Object(Magento\\Sales\\Model\\Order), '\\Magento\\Sales\\...')\n#4 /var/www/html/magento/vendor/magento/framework/Webapi/ServiceOutputProcessor.php(107): Magento\\Framework\\Reflection\\DataObjectProcessor->buildOutputDataArray(Object(Magento\\Sales\\Model\\ResourceModel\\Order\\Collection), '\\Magento\\Sales\\...')\n#5 /var/www/html/magento/vendor/magento/framework/Webapi/ServiceOutputProcessor.php(59): Magento\\Framework\\Webapi\\ServiceOutputProcessor->convertValue(Object(Magento\\Sales\\Model\\ResourceModel\\Order\\Collection), '\\Magento\\Sales\\...')\n#6 /var/www/html/magento/vendor/magento/module-webapi/Controller/Rest.php(270): Magento\\Framework\\Webapi\\ServiceOutputProcessor->process(Object(Magento\\Sales\\Model\\ResourceModel\\Order\\Collection), 'Magento\\Sales\\A...', 'getList')\n#7 /var/www/html/magento/vendor/magento/module-webapi/Controller/Rest.php(160): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#8 /var/www/html/magento/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#9 /var/www/html/magento/vendor/magento/framework/App/Http.php(115): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#10 /var/www/html/magento/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#11 /var/www/html/magento/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#12 {main}"
}
And I've tried to do other conditions and fields, like getting every order with a grand_total
greater than 100 (i.e. "gt" and "100") but that fails with the same error message. If I do a regular "eq" condition type, then it works.
Can anyone help me understand what I'm doing wrong? Let me know if I need to clarify my question with more examples or something.
Edit: It seems whenever the order API returns more than one item, this error occurs.
Edit 2: This is the request I'm trying to make: /rest/V1/orders?searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bfield%5D=grand_total&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bvalue%5D=80&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bcondition_type%5D=gt&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B1%5D%5Bfield%5D=grand_total&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B1%5D%5Bvalue%5D=90&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B1%5D%5Bcondition_type%5D=lt
. It's the built in REST interface, so nothing custom built. To add some context, if I do the exact same request against the invoices endpoint instead, I get the correct results (though invoices instead of orders, naturally).