So here\'s the request using curl:
curl -XPOST -H content-type:application/json -d \"{\\\"credentials\\\":{\\\"username\\\":\\\"username\\\",\\\"key\\\":\\\"
All others are too long here is a ONE LINER:
Net::HTTP.start('auth.api.rackspacecloud.com', :use_ssl => true).post(
'/v1.1/auth', {:credentials => {:username => "username",:key => "key"}}.to_json,
initheader={'Content-Type' => 'application/json'}
)
* to_json
needs require 'json'
OR if you want to
then:
ssl_opts={:use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE}
Net::HTTP.start('auth.api.rackspacecloud.com', ssl_opts) { |secure_connection|
secure_connection.post(
'/v1.1/auth', {:credentials => {:username => "username",:key => "key"}}.to_json,
initheader={'Content-Type' => 'application/json'}
)
}
In case it's tough to remember what params go where:
get
/post
/patch
/...
.HTTP.start()
: Creates a new Net::HTTP object, then additionally opens the TCP connection and HTTP session.HTTP.new()
: Creates a new Net::HTTP object without opening a TCP connection or HTTP session.