DEV Community

Chivaszx
Chivaszx

Posted on

Uri

require 'net/http'
require 'uri'

INSTANCE_URL = 'http://try.discourse.org/t/online-learning/108.json'
API_USERNAME = 'YOUR_USERNAME'
API_KEY = 'YOUR_API_KEY'

def send_request

url = URI.parse(INSTANCE_URL)
request = Net::HTTP::Put.new(url.path)
request.set_form_data({'api_username' => API_USERNAME, 'api_key' => API_KEY, 'category_id' => 5})
http = Net::HTTP.new(url.host, url.port)
response = http.request(request)

if response.code == '200'
  puts "Success!"
else
  puts "Error"
end

end

send_request

Top comments (0)