Add more parameters to WHERE expression

Place for developers to chat about the code
Post Reply
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']

User avatar
Aaron
Site Admin
Posts: 4554
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'"}

User avatar
Aaron
Site Admin
Posts: 4554
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 ==.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest