Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searchCatalogItems returns a 403 Forbidden response #683

Closed
misterakko opened this issue Apr 12, 2024 · 2 comments
Closed

searchCatalogItems returns a 403 Forbidden response #683

misterakko opened this issue Apr 12, 2024 · 2 comments

Comments

@misterakko
Copy link


name: searchCatalogItems returns a 403 Forbidden response
about: API call which worked under v5 of the library fails under v6.0.4
title: ''
labels: ''
assignees: ''


Problem description:

I am porting my code from v5 to v6 of the library, line by line.
It's mostly boring work, and I found no issues worth of the name but this.

The snippet of code I'm pasting just looks for an item by EAN in the Amazon catalog. It works under v5.
v5 code:

$amazon = new SaratAmazon($db); // initializes everything
$catApi = new SellingPartnerApi\Api\CatalogItemsV20201201Api($amazon->myConfig);
$answers = $catApi->searchCatalogItems('8804777427',
   array($amazon->prefs['amazon-MARKETPLACE_ID']),
   'salesRanks,identifiers,summaries')->getItems();

Error:

Client error: `GET https://sellingpartnerapi-eu.amazon.com/catalog/2022-04-01/items?marketplaceIds=8804777427&identifiers=APJ6JRA9NG5V4&identifiersType=salesRanks%2Cidentifiers%2Csummaries` resulted in a `403 Forbidden` response

Code

$amazon = new SaratAmazon($db); // calls ->make()->seller()
$catApi = $amazon->mySeller->catalogItems();
$answers = $catApi->searchCatalogItems(
   array('8804777427'),
   array($amazon->prefs['amazon-MARKETPLACE_ID']),
   'salesRanks,identifiers,summaries');
@jlevers
Copy link
Owner

jlevers commented Jun 10, 2024

Does this work for you? I think you have some arguments out of order, and the csv string changed to an array.

$answers = $catApi->searchCatalogItems(
    marketplaceIds: [$amazon->prefs['amazon-MARKETPLACE_ID']],
    identifiers: ['8804777427'],
    includedData: ['salesRanks', 'identifiers', 'summaries']
);

@misterakko
Copy link
Author

misterakko commented Aug 2, 2024

You are right. And: I will, starting from now, start to explicitly state the name of the parameter for every API call, because many need a bazillion and it's way too simple to mix things (PHPStorms helps but does not solve the issue, at least in my case).

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants