markandrus / twilio-haskell

Twilio library for Haskell
BSD 3-Clause "New" or "Revised" License
38 stars 39 forks source link

UnexpectedResponse when sending SMS #38

Closed Philonous closed 8 years ago

Philonous commented 9 years ago

I'm trying to send an SMS with this code:

Twilio.runTwilio ( twilioConf ^. account
                 , twilioConf ^. authToken
                 ) $ do
   let body = Twilio.PostMessage{ Twilio.sendTo = "+15005550010"
                                , Twilio.sendFrom = "+15005550006"
                                , Twilio.sendBody = "Hello"
                                }
   Twilio.post body

I'm using my test account credentials and the numbers from the magic numbers page.

The library throws an UnexpectedResponse exception (note that I have replaced possibly sensitive parts with [redacted]) :

UnexpectedResponse (Response {responseStatus = Status {statusCode = 201, statusMessage = "CREATED"}, responseVersion = HTTP/1.1, responseHeaders = [("Access-Control-Allow-Credentials","true"),("Access-Control-Allow-Headers","Accept, Autho
rization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since"),("Access-Control-Allow-Methods","GET, POST, DELETE, OPTIONS"),("Access-Control-Allow-Origin","*"),("Access-Control-Expose-Headers","ETag"),("Content-Type","application/json"),("Date","Thu, 05 Nov 2015 19:52:47 GMT"),("Strict-Transport-Security","max-age=15768000"),("Twilio-Request-Duration","0.104"),("Twilio-Request-Id","[redacted]"),("X-Powered-By","AT-5000"),("X-Shenanigans","none"),("Content-Length","726"),("Connection","keep-alive")], responseBody = "{\"sid\": \"SM6ca9e3d4c4fb4664801f80e8518055ad\", \"date_created\": \"Thu, 05 Nov 2015 19:52:47 +0000\", \"date_updated\": \"Thu, 05 Nov 2015 19:52:47 +0000\", \"date_sent\": null, \"account_sid\": \"[redacted]\", \"to\": \"+15005550010\", \"from\": \"+15005550006\", \"messaging_service_sid\": null, \"body\": \"Hello\", \"status\": \"queued\", \"num_segments\": \"1\", \"num_media\": \"0\", \"direction\": \"outbound-api\", \"api_version\": \"2010-04-01\", \"price\": null, \"price_unit\": \"USD\", \"uri\": \"/2010-04-01/Accounts/[redacted]/Messages/SM6ca9e3d4c4fb4664801f80e8518055ad.json\", \"subresource_uris\": {\"media\": \"/2010-04-01/Accounts/[redacted]/Messages/SM6ca9e3d4c4fb4664801f80e8518055ad/Media.json\"}}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) 

Installed twilio version is 0.1.3.0

markandrus commented 8 years ago

Thanks for the report, @Philonous. This might be due to some inconsistency in the JSON response. I will see if I can reproduce.

markandrus commented 8 years ago

@Philonous I think this may have to do with a change in the way .:? worked in aeson 0.10, which differs from both 0.9 and 0.11. I think I can correct this by specifying aeson 0.11 in a future 0.1.3.1 (which requires the fix to #39 first).

markandrus commented 8 years ago

@Philonous this should be fixed now. Can you test with 0.1.3.1? It should be available on Hackage now.

markandrus commented 8 years ago

I believe this is fixed. @Philonous please reopen if you notice this again.

Thanks! Mark

saurabhnanda commented 1 year ago

I'm on https://www.stackage.org/lts-18.28, which means I'm using aeson-1.5.6.0 and have added twilio-0.3.0.0 to my stack.yaml...

- twilio-0.3.0.0@sha256:155b6780dd90f1835172f1651aec9caf008f9359317629fb7e39ac07d37c7870,5892

... but I'm still hitting this error....

*** Exception: UnexpectedResponse (Response {responseStatus = Status {statusCode = 201, statusMessage = "Created"}