twilio / twilio-ruby

A Ruby gem for communicating with the Twilio API and generating TwiML
MIT License
1.35k stars 462 forks source link

Invalid value for DateSent when using next_page #71

Closed jeremygpeterson closed 10 years ago

jeremygpeterson commented 10 years ago

I'm converting from the old account.sms.messages logic to account.messages. I'm getting an "Invalid value for DateSent" message.

Steps to reproduce:

results = @client.account.messages.list(:date_sent => 24.hours.ago.strftime("%Y-%m-%d"), :page_size => 5) results.next_page

=> Twilio::REST::RequestError: Invalid value for DateSent

dougblack commented 10 years ago

@jeremygpeterson I'm taking a look at this and it's currently working for me. Let's see if we can debug what's going on.

What versions of

Also what does 24.hours.ago.strftime("%Y-%m-%d") print out at the rails console for you?

jeremygpeterson commented 10 years ago

I'm using twilio-ruby (3.11.4), rails (3.1.11) and ruby 1.9.3p194.

The 24.hours.ago.strftime("%Y-%m-%d") command prints out "2013-10-20".

dougblack commented 10 years ago

I'm trying to determine if this is a problem with the twilio-ruby library or the REST API. I'm assuming you have curl installed. If not let me know.

Try running the following command from your terminal, filling in the appropriate information where possible.

curl https://api.twilio.com/2010-04-01/Accounts/[Your AccountSid]/Messages\?DateSent\=2013-10-20&PageSize\=5 -u [YourAccountSid]:[YourAuthToken]
jeremygpeterson commented 10 years ago

Running the curl command, the urls all look like below:

nextpageuri="/2010-04-01/Accounts/[AccountSid]/Messages.json?DateSent=2013-10-20+00%3A00%3A00%2B00%3A00&PageSize=5&Page=1&AfterSid=SM0d9265223abe12e53db909896e788daf"
Beans0063 commented 10 years ago

I received a new report of this issue.

Reviewing the Twilio API response, it seems the next_page_uri format has changed in the Messages resource vs SMS/Messages. I will also file an internal API issue.

calh commented 10 years ago

Hi everyone,

I figured I should send a follow up to that. (I reported the issue to Brian) My code snippet to recreate looks like this:

    the_first = Date.today.at_beginning_of_month.strftime("%Y-%m-%d")
    messages = @twilio.account.messages.list("DateSent>" => the_first)
    begin
      messages = messages.next_page
    end while not messages.empty?

But if I change that to @twilio.account.sms.messages.list it works correctly.

jeremygpeterson commented 10 years ago

Thank you for the update.

carlosdp commented 10 years ago

This is a server-side API issue, if this problem persists, please contact Twilio Support.

jeremygpeterson commented 10 years ago

This issue is no longer a problem as I rewrote our app to respond to the sms_url.

Jeremy

Sent from my iPhone

On Jul 25, 2014, at 7:27 PM, Carlos Diaz-Padron notifications@github.com wrote:

This is a server-side API issue, if this problem persists, please contact Twilio Support.

— Reply to this email directly or view it on GitHub.