lib/preservation/client/versioned_api_service.rb in preservation-client-3.0.0 vs lib/preservation/client/versioned_api_service.rb in preservation-client-3.1.0

- old
+ new

@@ -50,10 +50,17 @@ # @param method [Symbol] :get or :post # @param path [String] path to be appended to connection url (no leading slash) # @param params [Hash] optional params def http_response(method, path, params) req_url = api_version.present? ? "#{api_version}/#{path}" : path - resp = connection.send(method, req_url, params) + resp = + case method + when :get + connection.get(req_url, params) + when :post + request_json = params.to_json if params&.any? + connection.post(req_url, request_json, 'Content-Type' => 'application/json') + end return resp.body if resp.success? errmsg = ResponseErrorFormatter.format(response: resp, client_method_name: caller_locations.first.label) raise Preservation::Client::UnexpectedResponseError, errmsg rescue Faraday::ResourceNotFound => e