Sorry, you need to enable JavaScript to visit this website.

You are here

When Using The Ruby SDK I'm Getting a "Bad request" Error

2 posts / 0 new
Last post

thoran's picture
by thoran

When Using The Ruby SDK I'm Getting a "Bad request" Error

The following (not the prettiest code): ... 

def deliver raise unless content && phone_number begin authentication_api_instance = p access_token = authentication_api_instance.auth_token(api_key, api_secret, grant_type) p access_token.access_token rescue Telstra_Messaging::ApiError => e puts "Exception when calling AuthenticationApi->auth_token: #{e}" return end Telstra_Messaging.configure do |config| config.access_token = access_token.access_token end message_segments.each do |message_segment| begin p send_sms_request = = phone_number send_sms_request.body = message_segment @responses << messaging_api_instance.send_sms(send_sms_request) rescue Telstra_Messaging::ApiError => e puts "Exception when calling MessagingApi->send_sms: #{e}" end end p @responses p messaging_api_instance.get_sms_status(message_id) if delivered? {success: true} else {failure: true} end end 


# "8uWKZclyhE71c2bvuMJu6jRtwyg1" # Exception when calling MessagingApi->send_sms: Bad Request [] Traceback (most recent call last): 6: from /Users/thoran/bin/sms:52:in `' 5: from /Users/thoran/bin/sms:39:in `main' 4: from /Users/thoran/lib/ruby/SMS.rb:42:in `deliver' 3: from /Users/thoran/lib/ruby/SMS/Service/Telstra.rb:75:in `deliver' 2: from /Users/thoran/.gem/ruby/2.5.3/gems/Telstra_Messaging- `get_sms_status' 1: from /Users/thoran/.gem/ruby/2.5.3/gems/Telstra_Messaging- `get_sms_status_with_http_info' /Users/thoran/.gem/ruby/2.5.3/gems/Telstra_Messaging- `call_api': Bad Request (Telstra_Messaging::ApiError) 

Not sure what's going wrong. I have followed the Ruby SDK examples and think I'm doing everything OK at my end. Ideas?


DeveloperSteve's picture
by DeveloperSteve

Hi Bulk

Heres some sample code that might help, did you provision a number on the api keys first?

require 'Telstra_Messaging'

api_instance =

client_id = "" # String | 

client_secret = "" # String | 

grant_type = "client_credentials" # String | 

result = api_instance.auth_token(client_id, client_secret, grant_type)

Telstra_Messaging.configure do |config|
  # Configure OAuth2 access token for authorization: auth
  config.access_token = result.access_token

api_instance =

#activate number 
arr = {'activeDays' => 10}

body =

result = api_instance.create_subscription(body)
p result

api_instance =

arr = {'to': 'mobile number', 'body' => 'hello world'};

payload =

result = api_instance.send_sms(payload)
p result


Log in or register to post comments