question

richa avatar image
richa asked ·

Fetching all orders using REST API instead of orders as per provided timestamp

I am trying to fetch orders using timestamp using API : "https://sandbox.dev.clover.com/v3/merchants/MID/employees/EMPID/orders?filter=clientCreatedTime>=1613627940000&filter=clientCreatedTime<=1613541600000";. When I hit this api in url it gives me correct result.

But when I hit this api in node js it gives me list of orders with other orders as well which are not in the provided timestamp.Can you please help me with why this issue is there?I am unable to understand the problem.

OrdersREST API
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.

1 Answer

· Write an Answer
David Marginian avatar image
David Marginian answered ·

We can't tell you what the problem is in your code if you haven't included any of your code to look at. I suggest that you take a look at your code in more detail.

2 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.

My code is as follows :

const options = {

method: 'GET',

url: 'https://sandbox.dev.clover.com/v3/merchants/'+clover_merchant_id+'/employees/'+body8.elements[k2].id+'/orders?filter=clientCreatedTime>=1613455200000&filter=clientCreatedTime<=1613800740000',

qs: {access_token:token1},

headers: {accept: 'application/json'}

};


request(options, function (error, response, body) {

if (error) throw new Error(error);

var body1=JSON.parse(body);

});

0 Likes 0 ·

Why aren't you passing the filters as part of the query string (qs)? I am not sure what library you are using to make the request, but when you pass special characters (>=) in a URL they need to be encoded correctly. I assume passing them in the qs will do that, otherwise you need to encode the querystring in the url you are passing. Also, you shouldn't be passing the access token in the query string, you should be using a header - https://docs.clover.com/docs/using-api-tokens

0 Likes 0 ·

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