Skip to content

🐛Error parsing valid JSON response #65

@rhec

Description

@rhec

Description

The JSON response from the server is failing to parse, because bamboozled is passing a HTTParty::Response object to JSON.parse. This will raise an exception: ArgumentError: strict_parse() expected a String or IO Object. That exception is caught, and bamboozled attempts to parse the JSON as XML, which also fails and raises an exception. That exception is not caught.

Expected behavior

The JSON from the server is parsed and returned.

How To Reproduce

irb(main):004:0> client = Bamboozled.client(subdomain: "<subdomain redacted>", api_key: "<api key redacted>")
irb(main):005:0> client.employee.all
MultiXml::ParseError: 1:1: FATAL: Start tag expected, '<' not found
	from (irb):5

Environment

Ruby 2.4.5

Dependencies:
httparty (0.13.3)
json (1.8.6)

Potential solution

Change JSON.parse(response) to JSON.parse(response.body) in base.rb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions