I see why this is happening now.
This issue is actually fixed on Faraday ver 0.9+, but that's only avaliable as an RC.
So two choices: Change your code to look like this (monkey patch, taken from Ruby's Faraday - include the same param multiple times)
require 'faraday'
module Faraday
module Utils
def build_nested_query(value, prefix = nil)
case value
when Array
value.map { |v| build_nested_query(v, "#{prefix}") }.join("&")
when Hash
value.map { |k, v|
build_nested_query(v, prefix ? "#{prefix}%5B#{escape(k)}%5D" : escape(k))
}.join("&")
when NilClass
prefix
else
raise ArgumentError, "value must be a Hash" if prefix.nil?
"#{prefix}=#{escape(value)}"
end
end
end
end
conn = Faraday.new(:url => 'http://foo.com:8888') do |faraday|
faraday.request :url_encoded
faraday.response :logger
faraday.adapter Faraday.default_adapter
end
response = conn.get '/api/endpoint', { :bar => ['baz', 'qux'] }
response.body
Or use the pre-release 0.9 version of faraday
gem install faraday --pre
and add this to your code:
faraday.params_encoder = Faraday::FlatParamsEncoder
Which will stop it from adding the []
symbols.