Search code examples
amazon-web-servicesamazon-selling-partner-api

Amazon sales api gives me a regex error, when i'm literally copying the dates from the documentation


in SP-API /sales endpoing, i get a regex error trying to hit it for interval, even though i'm copying the data from amazons own documentation.

URL

https://sellingpartnerapi-na.amazon.com/sales/v1/orderMetrics?marketplaceIds=ATVPDKIKX0DER&interval=2019-08-01T00:00-07:00--2018-08-02T00:00-07:00

response:

{
    "errors": [
        {
            "code": "InvalidInput",
            "message": "{getOrderMetrics.arg1=must match \"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{3})?(([+-]\\d\\d:\\d\\d)|Z)(\\[[a-zA-Z/_]+\\])?--[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{3})?(([+-]\\d\\d:\\d\\d)|Z)(\\[[a-zA-Z/_]+\\])?\"}",
            "details": ""
        }
    ]
}

Documentation

Example: 2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone.

Tried above URL, was expecting some sort of a response.


Solution

  • Your URL time is missing seconds. A request with the parameter:

    2019-08-01T00:00:00-07:00--2018-08-02T00:00:00-07:00
    

    will work correctly. As you can see in the docs, there is a seconds field.