1

Been trying to figure out what is going on here, but gotten stuck. Anyone got an idea as to what is going on. Using magento 2.2.4

( ! ) Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Catalog\Model\ProductRepository\Interceptor::getList() must be an instance of Magento\Framework\Api\SearchCriteriaInterface, string given in C:\wamp64\www\magento2\generated\code\Magento\Catalog\Model\ProductRepository\Interceptor.php on line 85 ( ! ) TypeError: Argument 1 passed to Magento\Catalog\Model\ProductRepository\Interceptor::getList() must be an instance of Magento\Framework\Api\SearchCriteriaInterface, string given in C:\wamp64\www\magento2\generated\code\Magento\Catalog\Model\ProductRepository\Interceptor.php on line 85

enter image description here

Code I try to execute:

set_time_limit(0);
define('TOKEN', 'token code');
define('URL', 'http://localhost:8080/magento2/index.php'); 
$headers = array("Authorization: Bearer ". TOKEN);
//API URL to get all Magento 2 modules
$requestUrl = (URL . "/rest/V1/products?searchCriteria=");
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
print_r($result);
2

You have to set the param value:

$requestUrl = (URL . "/rest/V1/products?searchCriteria=[]");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.