Closed mick-h closed 5 years ago
It looks like something is up with the request. I would expect to see "json-api"
as the phoenix_format under the private key and "application/vnd.api+json"
in the request's accept
key. Have you verified that everything is correct in the configuration? https://github.com/vt-elixir/ja_serializer#configuration
That was it. Though interestingly, the format encoder config specified in the README:
config :phoenix, :format_encoders,
"json-api": Poison
did not work, because Poison does not have a encode_to_iodata!
function. Jason does, so when I changed it to:
config :phoenix, :format_encoders,
"json-api": Jason
it worked fine.
Thanks for the fast response!
Hi there,
I'm trying to use JaSerializer 0.15.0 with Phoenix 1.4.9. I've added:
use JaSerializer.PhoenixView
to the view module, then changed the render call to:render(conn, "show.json-api", data: %{id: 1, name: "Joe", age: 43})
but when I hit the url I get the mentioned error:I can see that the render function in JaSerializer.PhoenixView gets called and returns
%{"data" => %{"attributes" => %{"age" => 43, "name" => "Mick"}, "id" => "1", "type" => "user"}, "jsonapi" => %{"version" => "1.0"}}
which looks fine, but it then seems to go astray in the controller code.Am I doing something wrong here? Any help much appreciated.
Mick