Created
September 29, 2010 21:25
-
-
Save phiggins/603593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
I am getting below error, when it is executed in debugging mode.
/home/fabritronix/.rvm/gems/ruby-2.3.0/gems/multi_xml-0.5.5/lib/multi_xml/parsers/nokogiri.rb:15:in
parse': EntityRef: expecting ';' (MultiXml::ParseError) from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/multi_xml-0.5.5/lib/multi_xml.rb:138:in
parse'from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/parser.rb:114:in
xml' from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/parser.rb:138:in
parse_supported_format'from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/parser.rb:105:in
parse' from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/parser.rb:67:in
call'from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/request.rb:345:in
parse_response' from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/request.rb:297:in
block in handle_response'from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/response.rb:25:in
parsed_response' from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/response.rb:80:in
method_missing'from /home/fabritronix/.rvm/gems/ruby-2.3.0/gems/httparty-0.14.0/lib/httparty/response.rb:48:in
inspect' from /home/fabritronix/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/debug.rb:663:in
block in debug_command'from /home/fabritronix/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/debug.rb:401:in
catch' from /home/fabritronix/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/debug.rb:401:in
debug_command'from /home/fabritronix/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/debug.rb:860:in
trace_func' from /home/fabritronix/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/debug.rb:1109:in
block in class:DEBUGGER__'