Add more parameters to WHERE expression

Please post requests related to the sipsorcery library to the GitHub repo https://github.com/sipsorcery/sipsorcery/issues.
Locked
rubinhozzz
Posts: 3
Joined: Sun Jul 17, 2016 8:02 pm

Add more parameters to WHERE expression

Post by rubinhozzz » Sun Jul 17, 2016 8:23 pm

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']

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Add more parameters to WHERE expression

Post by Aaron » Mon Jul 18, 2016 11:22 am

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

rubinhozzz
Posts: 3
Joined: Sun Jul 17, 2016 8:02 pm

Re: Add more parameters to WHERE expression

Post by rubinhozzz » Tue Jul 19, 2016 9:39 pm

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'"}

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Add more parameters to WHERE expression

Post by Aaron » Wed Jul 20, 2016 9:31 am

Try making it FromUser == ... , i.e. replace the single = with double equals ==.

Locked