1

I am getting the initial 10 records by the following step --

oauth = OAuth(client_key=CONSUMER_KEY, client_secret=CONSUMER_SECRET, resource_owner_key=TOKEN, resource_owner_secret=SECRET)
h = {'Content-Type': 'application/json', 'Accept': 'application/json'}
r = requests.get(url='0.0.0.0/api/rest/orders', headers=h, auth=oauth)

but I want the present day all records, and this is done in Python.

2 Answers 2

1

10 is the default limit result. To get the rest of the results either raise the limit by adding limit=100 for example to the parameters or page=2 for the next 10.

1

One solution is to change the limit to a higher amount and while looping, if the last item you retrieved is still in today's date then get the next page.

I updated this to code that should work, but I am unable to test it. Make sure you note the "from" date has a %20 between the date and time:

oauth = OAuth(client_key=CONSUMER_KEY, client_secret=CONSUMER_SECRET,
resource_owner_key=TOKEN, resource_owner_secret=SECRET)
h = {'Content-Type': 'application/json', 'Accept': 'application/json'}
r = requests.get(url='0.0.0.0/api/rest/orders?filter[0][attribute]=created_at&filter[0][from][0]=2015-10-29%2000:00:00', headers=h, auth=oauth)
4
  • THANKS.... worked in a single shot ... but am wondering is there any way in which we can pass the current date. By this we can get the record of a specific day rather than looping and then checking the records. Oct 29, 2015 at 5:46
  • Nilay, see the edited version of the answer above. I cannot test, but it should be on the right path. Let me know if you have issues with it. I will test if time permits. Oct 29, 2015 at 21:59
  • hey thanks for the help, but its not working. error :: ` ValueError: Error trying to decode a non urlencoded string. Found invalid characters: set([u'[', u':', u']']) in the string: 'filter[0][attribute]=created_at&filter[0][from][0]=2015-10-29%2000:00:00'. Please ensure the request/response body is x-www-form-urlencoded.` and a more thing if it works fine then will it return only 10 records or the complete records? if it is 10 records then do i have to raise the limits to get all records ? Oct 30, 2015 at 6:04
  • Nilay, /api/rest/orders?filter[0][attribute]=created_at&filter[0][from][0]=2015-02-13%2000:00:00 works fine for me, tested on EE 1.14.1. Make sure, if you are copying and pasting that you don't have a strange single quote character. If you don't get them all, set an artificially high limit that's more than you should receive in a day. Oct 30, 2015 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.