CatalogItemsV20220401Api->searchCatalogItemsRequest() throws an exception with PHP 8.x
While upgrading from PHP 7.x to 8.x, CatalogItemsV20220401Api->searchCatalogItemsRequest() throws the following exceptions:
Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /workspace/vendor/jlevers/selling-partner-api/lib/Api/CatalogItemsV20220401Api.php:856 Stack trace: #0 /workspace/vendor/jlevers/selling-partner-api/lib/Api/CatalogItemsV20220401Api.php(856): count('A1RKKUPIHCS9HS') #1 /workspace/vendor/jlevers/selling-partner-api/lib/Api/CatalogItemsV20220401Api.php(529): SellingPartnerApi\Api\CatalogItemsV20220401Api->searchCatalogItemsRequest('A1RKKUPIHCS9HS', '0196432747160,0...', 'EAN', 'summaries, iden...', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) #2 /workspace/vendor/jlevers/selling-partner-api/lib/Api/CatalogItemsV20220401Api.php(503): SellingPartnerApi\Api\CatalogItemsV20220401Api->searchCatalogItemsWithHttpInfo('A1RKKUPIHCS9HS', '0196432747160,0...', 'EAN', 'summaries, iden...', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) #3 /workspace/a/workers.module.php(4562): SellingPartnerApi\Api\CatalogItemsV20220401Api->searchCatalogItems('A1RKKUPIHCS9HS', '0196432747160,0...', 'EAN', 'summaries, iden...', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
Based on the error, it looks like you're passing a single marketplace ID instead of an array of marketplace IDs.
Hi jlevers, appreciate the swift response.
I am passing "A comma-delimited list of Amazon marketplace identifiers for the request" - I'm quoting the comment from the documentation [1] and not an array.
Even if using an array, the exact same exception is thrown.
[1] https://github.com/jlevers/selling-partner-api/blob/main/docs/Api/CatalogItemsV20220401Api.md
After looking at the code, indeed there is nothing wrong with it.
It's just the instructions in the comments next to the arguments that are misleading: "string[] | A comma-delimited list of Amazon marketplace identifiers ..." "A comma-delimited list of product identifiers ..."
There is no "comma-delimited list", these are all arrays.
Thanks for your time.
Got caught by this too. For anyone else -- both $identifiers and $marketplace_ids args expect arrays and not comma-delimited strings (and other arguments saying "comma-delimited list" for that matter).
Main gotcha comes from the fact that I already used getCatalogItem by sending it a single marketplace id string and it worked without issues, so I assumed that is the correct usage, but it actually only works by accident.