Skip to content

Instantly share code, notes, and snippets.

@travisdmathis
Created October 2, 2012 22:06
Show Gist options
  • Select an option

  • Save travisdmathis/3823619 to your computer and use it in GitHub Desktop.

Select an option

Save travisdmathis/3823619 to your computer and use it in GitHub Desktop.
/Users/fluffheadsr/.rvm/gems/ruby-1.9.3-p125/gems/json-1.7.5/lib/json/ext/parser.bundle: undefined class/module Encoding (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/fluffheadsr/.rvm/gems/ruby-1.9.3-p125/gems/json-1.7.5/lib/json/ext.rb:13
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/fluffheadsr/.rvm/gems/ruby-1.9.3-p125/gems/json-1.7.5/lib/json.rb:58
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
from ./registraion.rb:6
#!/usr/bin/ruby
require 'net/http'
require 'rubygems'
require 'json'
### Server Details
@server=""
@api="/zabbix/api"
### Login Details
@login_user=""
@login_pass=""
### JSON
@api_login ={
"user" => @login_user,
"password" => @login_pass,
"id" => "1"
}.to_json
def authenticate
req = Net::HTTP::Post.new(@api, initheader = {'Content-Type' =>'application/json'})
req.basic_auth @login_user, @login_pass
req.body = @api_login
response = Net::HTTP.new(@server).start {|http| http.request(req) }
puts "Response #{response.code} #{response.message}:
#{response.body}"
end
auth = authenticate
puts auth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment