On Oct 7, 10:01 am, "Kaushalya K." <[email protected]> wrote: > Hi, > > I am quite new to ruby and am programming an application to send sms > using rest_client gem. I so far have code on one of my modules which > tries to send an sms to a number. It gives the 403 error - > > RestClient::Forbidden in SMSController#index > > 403 Forbidden > Rails.root: /Users/user1/Desktop/rails_projects/sms_app > > My code in the module looks as follows - before adding this code i had a > simple enter number and enter message text boxes with the usual > edit/add/delete options. > > require 'rubygems' > require 'rest_client' > > class SMS < ActiveRecord::Base > > API_URL = 'http://services.xxxx.com/SMS' > API_KEY = '000000000' > RestClient.post 'API_URL/TXT/XXXX/07996750812/wakeup/API_KEY', > :number => '079945460812', :nested => { :message => 'working from > inside' } > RestClient.get 'https://[email protected]:password@API_URL' > end > > My user name is in the form of an email. let me what you think the > problem would be. thanks :)
First off, it's a bit odd to be making those calls to restclient where you're making them - they'll happen when the class gets loaded, which isn't really under your control. Secondly you don't seem to be using ruby's interpolation properly - API_URL isn't getting replaced by the value of that constant Lastly, @ is a special character in a url (since it marks the separation between the end of the password and the rest of the url), so you'll need to escape the literal @ in your username (I'd be surprised if there wasn't a way in rest client to just supply a username and password rather than have to do that mangling yourself) Fred > > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

