Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce REST API - Get Orders using after/before parameters

I'm using the WooCommerce REST API (http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction) and are able to download Customers, Orders etc successfully. I would now like to just download a list of Orders between 2 dates - I can see in the docs for Orders the following parameters:

after   string  Limit response to resources published after a given ISO8601 compliant date.
before  string  Limit response to resources published before a given ISO8601 compliant date.

I've modified the URL for the request to this:

https://mywebsite.com/wp-json/wc/v1/orders?after=2016-08-05&before=2016-08-06&page=1

but I'm getting a 400 error with this response:

{
  "code": "rest_invalid_param", 
  "data": {
    "params": {
      "after": "The date you provided is invalid.", 
      "before": "The date you provided is invalid."
    }, 
    "status": 400
  }, 
  "message": "Invalid parameter(s): after, before"
}

The 2 dates are valid ISO8601 compliant dates as far as I can tell. Can't find an example of how this request should look so not sure where to go from here.

like image 471
user982124 Avatar asked Feb 05 '23 14:02

user982124


1 Answers

It turns out you need to also specify the time, e.g.

after=2016-11-20T13:57:31.2311892-04:00
like image 65
user982124 Avatar answered Feb 24 '23 20:02

user982124