Reputation: 7783
Why are x-mws-quota-max
, x-mws-quota-remaining
and x-mws-quota-resetsOn
headers always omitted from Amazon's response to my API calls?
We are receiving request throttling exceptions in our order importer and I can't seem to figure out why, or at least why we can't see any throttling headers.
We request the MWS Orders API. First we list orders with the ListOrders
operation, then for each order we ListOrderItems
operation to grab the item details, which we then use internally for things like stock and reports. We use the Marketplace Web Service Order PHP SDK (@version 2013-09-01
) to do this and run it on a cron job that runs every 15 minutes, all day, with each request limiting the scope of orders its pulling to only retrieve ones since the last cron instance ran.
In the documentation about throttling and on the API documentation itself, it speaks about the header items to provide feedback on your usage. For example:
x-mws-quota-max: 3600
x-mws-quota-remaining: 10
x-mws-quota-resetsOn: Wed, 06 Mar 2013 19:07:58 GMT
However, none of our requests are returning this data. When I try getQuotaMax()
and other getters from the ResponseHeaderMetadata
object, they all return null. If I dump the curl request directly I get the following:
HTTP/1.1 200 OK
Server: Server
Date: Wed, 31 Jan 2018 10:30:20 GMT
Content-Type: text/xml
Content-Length: 182649
Connection: keep-alive
X-Amz-Date: Wed, 31 Jan 2018 10:30:20 GMT
x-amzn-Authorization: AAA SignedHeaders=X-Amz-Date, identity=com.amazon.aaa.MarketplaceWebServiceOrders.AndromedaControlService.amzn1.aaa.id.lwigtwr3h4inoeknjer76q4tl4.Default/1, Signed=true, Encrypted=false, Signature=M/AAAAexATrzvpAAAAAKJIK9mkwsBjPryIWcvnAAAAA=, Algorithm=HmacSHA256
x-mws-request-id: 9f4f29a2-aaaa-4eca-9c7a-8023bea06fab
x-mws-timestamp: 2018-01-31T10:30:19.677Z
x-mws-response-context: aaaaaLSsB3L83dPqsIYmrA3VnhhMZypSJ2yQ9sxK//zDuOBUUuCyYdPzCiDrgrrzqw/BJLbPVAo=
Vary: Accept-Encoding,User-Agent
<?xml version="1.0"?>
<ListOrdersResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
<ListOrdersResult>
<Orders>
...
The exceptions that are caught on the nightly cron jobs seem to confirm that a) throttling is the issue and b) we aren't receiving anything back:
Caught Exception: Request is throttled
Response Status Code: 503
Error Code: RequestThrottled
Error Type: Unknown
Request ID: 94a816fd-d7cb-aaaa-9c46-d97ef4b338b1
XML: <?xml version="1.0"?>
<ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
<Error>
<Type></Type>
<Code>RequestThrottled</Code>
<Message>Request is throttled</Message>
</Error>
<RequestID>94a816fd-d7cb-aaaa-9c46-d97ef4b338b1</RequestID>
</ErrorResponse>
ResponseHeaderMetadata: RequestId: 94a816fd-d7cb-44a5-9c46-d97ef4b338b1, ResponseContext: Yzi1erdrrVZuGBzvtiUxd/94+Mj6QcN9BJReTcsg+MkelvfcYETwNjBER3CWqNhmA87P6n7sTq8=, Timestamp: 2018-01-30T22:00:59.545Z, Quota Max: , Quota Remaining: , Quota Resets At:
We never experienced this problem before, but now we're are making more sales on Amazon it's inevitable. However, am I missing something obvious in terms of actually getting the throttling headers so I can actually put in place counter-measures?
As a side note I don't think an hourly request limit, in addition to throttling, applies here as it says it only applies to the Products, Reports, and Feeds APIs in the above linked throttling documentation. A final side note is that we're not using a proxy and connect directly from the PHP script to the Amazon servers.
Upvotes: 3
Views: 852
Reputation: 191
Not sure about the PHP MWS client, but the C# one doesn't actually fetch these parameters from the ResponseHeader. So you need to modify the MWS client code yourself a bit to specifically get your hands on these response header parameters.
I imagine this could be true for the PHP client as well.
The changes that need to be made in the C# MWS client in order to get these response params are:
Upvotes: 1