running ruby file.rb
, gives me .rvm/gems/ruby-2.2.6/gems/httpclient-2.6.0.1/lib/httpclient.rb:535:in 'set_auth': wrong number of arguments (2 for 3) (ArgumentError)
file.rb:
require 'savon'
url = 'https://website.com/services/'
login = Base64.strict_encode64("2111:232330:OunOi28")
client = Savon.client(
endpoint: url,
namespace: url,
log: true,
pretty_print_xml: true,
basic_auth: "Basic #{login}"
)
response = client.call(:something)
Note: I have to send 3 credentials, currently passing them in the login variable.
How can I define this set_auth
in the client or the call on the client?
Stacktrace:
from .rvm/gems/ruby-2.2.6/gems/httpi-2.4.1/lib/httpi/adapter/httpclient.rb:54:in 'setup_auth'
from .rvm/gems/ruby-2.2.6/gems/httpi-2.4.1/lib/httpi/adapter/httpclient.rb:43:in 'setup_client'
from .rvm/gems/ruby-2.2.6/gems/httpi-2.4.1/lib/httpi/adapter/httpclient.rb:25:in
'request'
from .rvm/gems/ruby-2.2.6/gems/httpi-2.4.1/lib/httpi.rb:161:in 'request'
from .rvm/gems/ruby-2.2.6/gems/httpi-2.4.1/lib/httpi.rb:133:in 'post'
from .rvm/gems/ruby-2.2.6/gems/savon-2.11.1/lib/savon/operation.rb:94:in 'block in call_with_logging'
from .rvm/gems/ruby-2.2.6/gems/savon-2.11.1/lib/savon/request_logger.rb:12:in 'call'
from .rvm/gems/ruby-2.2.6/gems/savon-2.11.1/lib/savon/request_logger.rb:12:in 'log'
from .rvm/gems/ruby-2.2.6/gems/savon-2.11.1/lib/savon/operation.rb:94:in 'call_with_logging'
from .rvm/gems/ruby-2.2.6/gems/savon-2.11.1/lib/savon/operation.rb:54:in 'call'
from .rvm/gems/ruby-2.2.6/gems/savon-2.11.1/lib/savon/client.rb:36:in 'call'
from file.rb:18:in '<main>'
You not need to pass an Array to the :basic_auth
parameter, i.e.:
client = Savon.client(
endpoint: url,
namespace: url,
log: true,
pretty_print_xml: true,
basic_auth: [login, password] # (Whatever the password is??)
)
The error comes from here in the source code; it is expecting an array of a username and password.
See the Authentication section of the documentation for correct usage:
Authentication
HTTP authentication will be used for retrieving remote WSDL documents and actual SOAP requests.
basic_auth
Savon supports HTTP basic authentication.
Savon.client(basic_auth: ["luke", "secret"])
[...]