Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'httparty'
- require 'vine'
- class Hash
- def to_xml
- map do |k, v|
- text = v.class==Hash ? v.to_xml : v
- "<%s>%s</%s>" % [k, text, k]
- end.join
- end
- end
- hash={"client" =>
- {"first_name"=>"rishabh",
- "last_name" =>"adi",
- "organization" =>"test",
- "email"=>"foobar@xml.com"
- }
- }
- auth={:username =>API_KEY, :password => "X"}
- string ="<?xml version=\'1.0'\ encoding= \'utf-8'\ ?>
- <request method=\'client.create'> #{hash.to_xml} </request>"
- response=HTTParty.post(API_URL,
- :body => string,
- :basic_auth => auth
- )
Add Comment
Please, Sign In to add comment