3

I started a brand new Phoenix project and am using JASerializer for my JSON API. I followed the documentation for what to add to my project, so I have:

config/config.esx

config :phoenix, :format_encoders,
  "json-api": Poison

config :plug, :mimes, %{
  "application/vnd.api+json" => ["json-api"]
}

web/router.ex

pipeline :api do
  plug :accepts, ["json-api"]
  plug JaSerializer.ContentTypeNegotiation
  plug JaSerializer.Deserializer
end

And I used the JSON API Generator:

mix ja_serializer.gen.phoenix_api User users first_name:string last_name:string username:string email:string bio:text

I'm using Postman to test my requests, and here's what I see when I add some headers to it:

Accept */* returned a 200
Accept application/vnd.api+json returned a 406
Accept application/* returned a 406

So in my Phoenix server console, it's outputting:

[debug] ** (Phoenix.NotAcceptableError) no supported media type in accept header, expected one of ["json-api"]

I tried deleting the _build folder and recompiling the plugs which seemed to have work for some people, but not me.

What DID work was removing plug JaSerializer.ContentTypeNegotiation in my router, but that seems like an important piece that I shouldn't have to remove.

Does anyone have any ideas?

Here's the link to the Issue I submitted on the ja_serializer repo which might be helpful: https://github.com/AgilionApps/ja_serializer/issues/138#issuecomment-232998259

Drew
  • 6,736
  • 17
  • 64
  • 96

0 Answers0