1

Integrated Amazon Product Advisement API with my own application, It's working fine but the problem is:

To access the API we need time stamp, when I put the code on the server ( which is in other country), and used the server time stamp, then API gave the following error in the XML: "Request has expired. Timestamp date is XXXX-XX-XXTXX:XX:XXZ",

but when I enter my own time zone where currently I am, then its start working fine. Why API is working fine with client side timestamp, on the other hand all calculation related to API are happening on the server side.

I consult the following Developer document of Amazon API, but no avial. Product Advertising API Developer GuideAPI Version 2011-08-01

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Dawood Butt
  • 496
  • 6
  • 22

2 Answers2

3

var currentdate = new Date(); currentdate.toISOString();

This is how I got the time stamp for Product Advertising Api.

  • This is best—I was getting denied when not including milliseconds—```toISOString``` includes milliseconds automatically. – nikk wong Jun 01 '16 at 08:59
2

I consult the following Developer document of Amazon API, but no avial. Product Advertising API Developer GuideAPI Version 2011-08-01

Hum, this document clearly state the Timestamp parameter MUST be represented in Universal Time (UTC); You cannot send a local time, unless, by chance (which might be the case for your personal location) you happen to be on the same time as UTC:

"• Timestamp—Required. There is no default value. The time stamp you use in the request must be a dateTime object, with the complete date plus hours, minutes, and seconds (for more information, go to http://www.w3.org/TR/NOTE-datetime).This is a fixed -length subset of the format defined by ISO 8601, represented in Universal Time (GMT): YYYY-MM-DDThh:mm:ssZ (where T and Z are literals). Important If you are using .NET you must not send overly specific time stamps, due to different interpretations of how extra time precision should be dropped. To avoid overly specific time stamps, manually construct dateTime objects with no more than millisecond precision."

BernardG
  • 1,956
  • 3
  • 17
  • 25
  • 1
    Thanks for your reply. YES! I know all that, but the irony is that my Location is +5(UTC/GMT) and the server location is -6(UTC/GMT). But it works fine on +5(UTC/GMT). When I put +11 hours to the server time stamp(that of course become my own local time stamp), it works fine and gives error on all other time settings. Somehow currently I managed by putting +11 hours to the server time stamp. But it seems really strange. isn't it? – Dawood Butt Apr 29 '13 at 12:03
  • Yes, it's pretty stange. Which language are you using? I bet it has, like basically all others, a function to convert local time to utc, so that you would not have to do anything specific/different between your station and the server. I am in France, my server is on the US West Coast, and I don't have anything specific to do.... – BernardG Apr 30 '13 at 12:29
  • I'm using ColdFusion. Here is my syntax to do that with 11 hours: ` `. – Dawood Butt May 01 '13 at 05:40
  • You are saying using buit-in function to do that, I think something like this: [Converting To And From GMT / UTC Time In ColdFusion Using DateConvert()](http://www.bennadel.com/blog/1596-Converting-To-And-From-GMT-UTC-Time-In-ColdFusion-Using-DateConvert-.htm). But I think it will do the same as my syntax is doing. – Dawood Butt May 01 '13 at 05:43