Page 1 of 1

Add more parameters to WHERE expression

Posted: Sun Jul 17, 2016 8:23 pm
by rubinhozzz
I'm trying to get the calls for a specific number. However I want to extend that but getting the calls between an interval of dates. How can I accomplish that? (I'm using Python)

The code below just retrieves the first 10 records for that number. I would like to add more parameters to the WHERE expression.

Code: Select all

        url = SS_PROVISIONING_URL + 'cdr/get?where=FromUser="%s"&count=10' % (q.strip(),)
        r = requests.get(url, headers={'apikey':SS_API_KEY})
        result = r.json()
        records = r.json()['Result']

Re: Add more parameters to WHERE expression

Posted: Mon Jul 18, 2016 11:22 am
by Aaron

Code: Select all

url = SS_PROVISIONING_URL + 'cdr/get?where=FromUser="%s" and Created > "2016-01-27T22:00:00" and Created < ''2016-01-27T23:00:00" '
The datetime comparisons are done as a string operation so to get it to work correctly you need to specify the datetimes in the format:
yyyy-MM-ddTHH:mm:ss (where the T is literal and stands for time).

Re: Add more parameters to WHERE expression

Posted: Tue Jul 19, 2016 9:39 pm
by rubinhozzz
Thanks for the reply Aaron.

However, using that code...

Code: Select all

url = SS_PROVISIONING_URL + 'cdr/get?where=FromUser="%s" and Created > "2016-01-27T22:00:00" and Created < "2016-01-27T23:00:00" ' % (q.strip(),)
gives me the following error...

Code: Select all

{u'Result': None, u'Success': False, u'Error': u"Operator 'and' incompatible with operand types 'Boolean' and 'String'"}

Re: Add more parameters to WHERE expression

Posted: Wed Jul 20, 2016 9:31 am
by Aaron
Try making it FromUser == ... , i.e. replace the single = with double equals ==.