Obelich
1/15/2019 - 12:49 AM

RbRestClientPost

response = RestClient::Request.new({
      method: :post,
      url: "[URL]",
      user: 'someone',
      password: 'mybirthday',
      payload: { post_this: 'some value', post_that: 'other value' },
      headers: { :accept => :json, content_type: :json }
    }).execute do |response, request, result|
      case response.code
      when 400
        [ :error, parse_json(response.to_str) ]
      when 200
        [ :success, parse_json(response.to_str) ]
      else
        fail "Invalid response #{response.to_str} received."
      end
    end