2

I'm unable to fetch response or send request to exotel sms api using the provided documentation on exotel rubygem http://www.rubydoc.info/gems/exotel/0.2

The documentations says to fetch response as follows:

sms = Exotel::Sms.details(sms_id)

But when I do that with an sms_id, ex. sms_id='12345678901234567890' like

sms = Exotel::Sms.details("12345678901234567890")

it gives an error

TypeError: no implicit conversion of HTTParty::Response into String

I do have httparty gem installed. How to solve this?

Jesse Sravya
  • 121
  • 1
  • 2
  • 9
  • 1
    'exotel' was last updated on February 23, 2013. There is a good chance that it is expecting a different version on httpary. In the source for this gem they are using httparty (0.10.2). I would try changing httparty to that version and see if you get the same error. – nzajt Sep 13 '17 at 14:43

1 Answers1

3

The library is tested with 0.9.0 version of httparty that used to respond with Hash for http requests and the code is assuming it is string if not Hash and that is why it is failing

Here is the line causing the problem

exotel/response.rb

Quick fix would be to use 'httparty=0.9.0'

You may do it by using

gem "httparty","0.9.0"

Here is a working sample code, please update the account_sid and token with yours

gem "httparty","0.9.0"
require "exotel"

account_sid = "testexotel"
token = "9dcb4*******************e1dc2174fc47" 

Exotel.configure do |c|
  c.exotel_sid   = account_sid
  c.exotel_token = token
end

sms = Exotel::Sms.details("40a7*********258d411898b18b")
puts sms.status
puts sms.date_sent