Skip to content

Instantly share code, notes, and snippets.

@railsfactory-kumaresan
Forked from phiggins/httparty_example.rb
Last active August 29, 2015 14:08
Show Gist options
  • Save railsfactory-kumaresan/8011a4128d311a31578d to your computer and use it in GitHub Desktop.
Save railsfactory-kumaresan/8011a4128d311a31578d to your computer and use it in GitHub Desktop.
require 'httparty'
class Webservice
CANDIDATE = <<XML
<Candidate xmlns="com.mysite/2010/10/10" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<FirstName>%s</FirstName>
<LastName>%s</LastName>
<Email>%s</Email>
<Gender>%s</Gender>
</Candidate>
XML
include HTTParty
format :xml
base_uri 'mysite.com'
default_params :authorization => 'xxxxxxx'
def self.add_candidate(first_name,last_name,email,gender)
body = CANDIDATE % [first_name, last_name, email, gender]
post('/test.xml', :body => body)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment