jsmestad / jsonapi-consumer

Client framework for consuming JSONAPI services in Ruby
https://github.com/jsmestad/jsonapi-consumer
Apache License 2.0
94 stars 18 forks source link

Requests not formatted properly #19

Closed tbhockey closed 6 years ago

tbhockey commented 6 years ago

We're using JSONAPI::Resource to serve an API and are attempting to consume this API with jsonapi-consumer. I can curl the API just fine and everything works as expected. But when I use your gem, the request is not formatted correctly. See below:

class Brand
  include JSONAPI::Consumer::Resource
  self.host = "http://localhost:4000/api/v2/"
end
> Brand.find 1
JSONAPI::Consumer::Errors::BadFormat: 406 GET http://localhost:4000/api/v2/brands/1 {"errors":[{"title":"Not acceptable","detail":"All requests must use the 'application/vnd.api+json' Accept without media type parameters. This request specified 'application/json'.","code":"406","status":"406"}]}
from /Users/tonybeninate/.rvm/gems/ruby-2.4.1@audiogon/gems/jsonapi-consumer-0.1.1/lib/jsonapi/consumer/middleware/raise_error.rb:6:in `on_complete'

I don't see any mention of this in the docs and it seems that this should be the default configuration out of the gate using your gem. Am I missing something here? Thanks.

jsmestad commented 6 years ago

@tbhockey I am guessing the JSONAPI your using is the final version. This gem was originally built for the RC releases and am unsure if its been maintained.

tbhockey commented 6 years ago

Ok. Thanks @jsmestad

jsmestad commented 6 years ago

This has been re-built and v1.0.x has been released.