Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created September 29, 2010 21:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phiggins/603593 to your computer and use it in GitHub Desktop.
Save phiggins/603593 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
@kirantpatil
Copy link

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:inparse'
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:inparse_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:incall'
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:inblock 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:inmethod_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:inblock 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:indebug_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:inblock in class:DEBUGGER__'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment