airborne icon indicating copy to clipboard operation
airborne copied to clipboard

ARRAY: Api request returned invalid json (Airborne::InvalidJsonError)

Open papitodev opened this issue 8 years ago • 6 comments

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. :(

papitodev avatar Mar 27 '17 22:03 papitodev

up

papitodev avatar Mar 28 '17 13:03 papitodev

Rest Client does not accept json body with array ??

papitodev avatar Mar 30 '17 23:03 papitodev

up

papitodev avatar Apr 04 '17 19:04 papitodev

up

papitodev avatar Apr 17 '17 18:04 papitodev

up

papitodev avatar May 08 '17 15:05 papitodev

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)
...

rdalverny avatar Jul 27 '17 16:07 rdalverny