Getting bad request for italy and spain
Guacam-Ole opened this issue · 5 comments
I use the following code to access the api: (just like in the examples)
$conf = new GenericConfiguration();
$client = new \GuzzleHttp\Client();
$request = new \ApaiIO\Request\GuzzleRequest($client);
$conf
->setCountry($country)
->setAccessKey('...')
->setSecretKey('...')
->setAssociateTag($affili)
->setRequest($request);
$apaiIO = new ApaiIO($conf);
$search = new Search();
$search->setCategory('All');
$search->setResponseGroup(array('Small','Images','OfferSummary'));
$search->setKeywords('HX400');
$response = $apaiIO->runOperation($search);
$result = simplexml_load_string($response);
$country is "de", "it", "es", "fr", "co.uk", ...
AssociateTag and Request are always the same, while "$affili" changes according to the country.
While de, fr and co.uk works just fine I receive a "Bad Request" error on "es" (spain) and "it" (italy):
Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error:
GET http://webservices.amazon.it/onca/xml?AWSAccessKeyId=...&AssociateTag=...&Keywords=hx400&Operation=ItemSearch&ResponseGroup=Small%2CImages%2COfferSummary&SearchIndex=All&Service=AWSECommerceService&Timestamp=2017-01-12T20%3A44%3A58Z&Version=2013-08-01&Signature=...
resulted in a400 Bad Request
response:<ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2013-08-01/"><Error><Code>AWS.Invalid (truncated...)
' in C:\dev\amznclient\site\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:111
Stack trace:
#0 C:\dev\amznclient\site\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 C:\dev\amznclient\site\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure} in C:\dev\amznclient\site\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 111
The $affili is correct and validated, the other parameters, too (obviously, as they work on the other countries). Is there maybe a wrong url for italy and spain used in this repo ?
I tried this with different amazon-accounts. Every time the same issue: Everything but spain/italy works
For more information you need to have a look on the error which occurs <ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2013-08-01/"><Error><Code>AWS.Invalid (truncated...)
You see that the xml is (truncated...). So please try to get the full XML and see whats written inside.
If you are having trouble accessing the full error message try the following:
try {
...
} catch (\GuzzleHttp\Exception\ClientException $e) {
echo $e->getResponse()->getBody()->getContents();
}
All thanks go to: https://laracasts.com/discuss/channels/general-discussion/guzzle-error-message-gets-truncated?page=1
My error message was:
AWS.InvalidAssociateYour XXXXXXXXXXXXXXXXX is not registered as an Amazon Associate. Please register as an associate at https://programma-affiliazione.amazon.it/gp/associates/join/landing/main.html.eed99828-7eba-4353-8f89-5c9bd5bbb6bf
When I try join it tells me I am already joined? So not sure how to diagnose the problem with accessing the API for the Spanish and Italian stores.
I did the following and am now receiving results. Have no idea which bits mattered.
- Generated a product link from within the affiliate console and sent some clicks.
- Opened the welcome email and clicked the third checkbox (which is unchecked) and it allowed me to sign up again with and generate a new Amazon tracking ID.
- Clicked through the tour and the option screen asking if a US citizen and also set a payment methods as gift card to Amazon account for now.
Within a minute or so the API was returning results. Good luck.
I'll try that, thx