0

When connecting to an API, the command

TwilioClient.new.send_text(@user, @reminder.message)

fails for motive: ArgumentError (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true)

Firstly, the message is misleading given that there is no particular link involved as the only linking element between the application and the Twilio API is a phone_number, an account_sid and auth_token (although there may be one in the twilio-ruby gem). In addition, the config/environments/development.rb file has its entry

config.action_mailer.default_url_options = { host: 'test.domain.com' }

so either there is a problem in parsing the file (which was not manifest before the introduction of this method invoking above command) or this is referencing some other object with a different name (and thus misleading with the error message)

update
the following line in the method is the culprit

status_callback: update_twilio_reminder_url(@reminder.user_id)

I had to evade the helper function as no syntax was of use & build the URL from its host/controller/action/id components

Jerome
  • 5,583
  • 3
  • 33
  • 76
  • I don't see any commands looking here at the Ruby code example, https://www.twilio.com/docs/sms/send-messages. Is this an application you built on top of the API? I found another Stackoverflow article mentioning a similar error - https://stackoverflow.com/questions/7219732/missing-host-to-link-to-please-provide-host-parameter-or-set-default-url-optio. – Alan Apr 16 '20 at 11:16
  • I found the culprit (question updated) and a path [ahem] to a solution, but it certainly does not leverage the internal helper functions (which at this point may be more convoluted than piecing together the elements. – Jerome Apr 16 '20 at 12:08
  • Hey @Jerome, can you share the code you are using that was causing this issue? I'm a little concerned you have an extra gem here that is getting in the way of things (and bulking up your application). Also, where are you calling the code to send the message? I think I can help with a clearer description of what is going wrong, but I need to know what you have in the first place. Thanks! – philnash Apr 17 '20 at 04:13
  • Oh the culprit is the rails url helper, not a Twilio thing. Building the URL manually (i.e. avoiding the helper) allows the callback to post where it should. – Jerome Apr 17 '20 at 05:46

0 Answers0