question

coder12 avatar image
coder12 asked David Marginian commented

Clover order not filtering by clientCreatedTime

I am trying to use the V3 api to fetch back orders between a time. I convert the data time to unix and pass it to the backend but for some reason the api returns every order back from december.


my code is:

maxDate= 1614018958000;
minDate= 1582327252000
const options = {
    method: 'get',
    url: config.cloverApiUrl +'/v3/merchants/'+data.merchant_id
      +'/orders?limit=1000&expand=lineItems&filter=clientCreatedTime>' +minDate +'&filter=clientCreatedTime<'+maxDate,
    qs: {access_token: data.token}
  };
  return response = request(options);

but instead of getting orders between that time frame, I get orders ranging between the following time. I tried everything but it still returns back orders between the below date rather than the date specified in the code

  1. max: 1614018958000
  2. min: 1582327252000
OrdersREST API
7 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

coder12 avatar image coder12 David Marginian ♦♦ ·

So I changed it to pass the filters as queryParams (shown below) as mentioned in the other posts answer but for some reason no matter what date I put it is not returning any item back. I tried it with different dates but still doesn't return anything. then I get all orders back. I tried doing the filter from postman as well but same response.

 const options = {
    method: 'get',
    url: config.cloverApiUrl +'/v3/merchants/'+data.merchant_id
      +'/orders',
    headers: {
      Authorization: 'Bearer ' + token,
      ContentType: 'application/json'
    },
    qs: {
      filter: `clientCreatedTime>` +minDate,
      filter: `clientCreatedTime<` +maxDate,
      expand: 'lineItems'
    }
  };


the response I get is

{"elements": [ ], "href": "http://sandbox.dev.clover.com/v3/merchants/myMerhcantId/orders?filter=clientCreatedTime%3C1613278800&filter=stateIS%20NOT%20NULL&limit=100"}


If I change the below code to flip the filter to

'clientCreatedTime<` +minDate,
'clientCreatedTime>` +maxDate

then I get all orders back but filter still doesn't work.

0 Likes 0 ·

What is your merchant id? Have you tried your query in Postman/curl, do you get different results?

0 Likes 0 ·
Show more comments

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community