Skip to content
Browse files

Trying JSON encode only for put, post

  • Loading branch information...
1 parent b53c159 commit ee54845b7d637dd4f2247a6b58c067132e5bc5f5 @gabriel committed
Showing with 6 additions and 3 deletions.
  1. +1 −1 lib/swiftype/connection.rb
  2. +5 −2 lib/swiftype/request.rb
View
2 lib/swiftype/connection.rb
@@ -8,7 +8,7 @@ def connection
@connection ||= begin
conn = Faraday.new(Swiftype.endpoint) do |b|
b.response :raise_error
- b.use FaradayMiddleware::EncodeJson
+ b.use Faraday::Request::UrlEncoded
b.use FaradayMiddleware::ParseJson
b.use FaradayMiddleware::Mashify
b.use ApiResponseMiddleware
View
7 lib/swiftype/request.rb
@@ -1,3 +1,5 @@
+require 'json'
+
module Swiftype
module Request
def get(path, params={}, options={})
@@ -24,11 +26,12 @@ def request(method, path, params, options)
when :delete, :get
request.url(path, params)
when :post, :put
+ request.headers['Content-Type'] = 'application/json'
request.path = path
- request.body = params unless params.empty?
+ request.body = ::JSON.dump(params) unless params.empty?
end
end
options[:raw] ? response : response.body
end
end
-end
+end

0 comments on commit ee54845

Please sign in to comment.
Something went wrong with that request. Please try again.