403 Error Dont know whats wrong.

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://yyy@gmail.com:password@API_URL’
end

My user name is in the form of an email. let me what you think the
problem would be. thanks :slight_smile:

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 = &#39;http://services.xxxx.com/SMS'
  API\_KEY = &#39;000000000&#39;
  RestClient\.post &#39;API\_URL/TXT/XXXX/07996750812/wakeup/API\_KEY&#39;,

:number => '079945460812', :nested => { :message => 'working from
inside' }
RestClient.get 'https://...@gmail.com:password@API_URL'
end

My user name is in the form of an email. let me what you think the
problem would be. thanks :slight_smile:

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