Skip to content

Instantly share code, notes, and snippets.

@stbenjam
Created December 9, 2014 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stbenjam/75cc79a7d2baaed316ee to your computer and use it in GitHub Desktop.
Save stbenjam/75cc79a7d2baaed316ee to your computer and use it in GitHub Desktop.
require 'rest-client'
require 'json'
require 'openssl'
uri = 'https://admin:changeme@katello-dev.bitbin.de/api/v2/hosts'
hostinfo = {}
hostinfo[:environment] = 'Standard_Base'
hostinfo[:hostgroup_id] = 2
hostinfo[:name] = 'testtest2'
body = {hosts: [hostinfo] }
headers = {"Content-Type" => 'application/json', "Accept" => 'application/json;version=2'}
request = RestClient::Request.new(
method: :post,
url: uri,
headers: headers,
payload: body.to_json
)
begin
request.execute
rescue => e
puts e.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment