Question

I am trying to retrieve my SMS log using the REST api but I can't figure out how to filter DateSent to be >= or <= than given date.

TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); 
Map<String, String> filters = new HashMap<String, String>();
filters.put("DateSent", "2014-04-27");
filters.put("To", "+XXXXXXXXX");    
MessageList messages = client.getAccount().getMessages(filters);

According to documentation here https://www.twilio.com/docs/api/rest/message#list-get-filters you are allowed to send >= or <=, but can't figure out where to put the inequality.

Was it helpful?

Solution

That Twilio documentation certainly is incomplete and confusing.

Try this: filters.put("DateSent>", "2014-04-27");

You can even pass two parameters to retrieve messages between dates:

filters.put("DateSent>", "2014-04-20");
filters.put("DateSent<", "2014-04-27");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top