Nomethoderror: Undefined method `Empty? ' for #<URI::HTTPS:0x000000063069d8>

Asked

Viewed 141 times

0

I am making a REST request but while executing I have this error:

NoMethodError: undefined method `empty?' for #<URI::HTTPS:0x000000063069d8>

My code:

  require 'net/http'


require 'uri'


def mandareq

  url = URI("https://gateway.plusmms.net/rest/message?")

  http = Net::HTTP.new(url.host, url.port)

  request = Net::HTTP::Post.new(url)

  request.body = {to:[number],text:'teste',from:'Remetente'}


  response = http.request(request)
  puts response.read_body

end

Some solution ?

1 answer

0


I managed to solve, just add the following code:

  http.use_ssl = true

Below this line :

  http = Net::HTTP.new(url.host, url.port)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.