airborne
airborne copied to clipboard
ARRAY: Api request returned invalid json (Airborne::InvalidJsonError)
I am sending a request inside an array, but an error 500 occurs with the message: Error: Api request returned invalid json (Airborne::InvalidJsonError)
@req = []
body = {
name: 'Paul Robias',
email: '[email protected]',
actualDate: '2017-03-27T17:19:21.944Z',
deviceCode: 'XPTODEVCODE123'
}
@req.push(body)
post 'http://127.0.0.1/user', @req, {"Content-Type" => 'application/json'}
puts json_body
This problem does not happen when I use Httparty. :(
up
Rest Client does not accept json body with array ??
up
up
up
I believe the culprit could be airborne/rest_client_requester.rb#L10:
module Airborne
module RestClientRequester
def make_request(method, url, options = {})
headers = base_headers.merge(options[:headers] || {})
res = if method == :post || method == :patch || method == :put
begin
request_body = options[:body].nil? ? '' : options[:body]
request_body = request_body.to_json if options[:body].is_a?(Hash)
RestClient.send(method, get_url(url), request_body, headers)
...