ember.js - Ember JsonApi with Jax-Rs content type on Posts -
i using ember-data
clientside , tomee7
jax-rs
on server.
i use ember-data's jsonapiadapter , adhere jsonapi specifications
if understand correctly, http communications must have content-type
header set application/vnd.api+json
the problem when try post server 415 unsupported media error
i've decorated services this:
@post @consumes("application/vnd.api+json") @path("somepostendpoint") public response postservice (@formparam "somedata" string somedata) { //.... }
but returned:
an application/x-www-form-urlencoded form request expected request media type application/vnd.api+json. consider removing @formparam annotations
when make request outside of emberdata (with postman) works fine.
i understand @formparam requires content-type: application/x-www-form-urlencoded
. use else?
it shame not use jsonapiadapter. :(
does have ideas try?
thanks!
ok colleague of mine figured out:
@path("somepostendpoint") @post @produces(value={"application/vnd.api+json",mediatype.application_json}) @consumes(value={"application/vnd.api+json",mediatype.application_json}) public response postservice (string somedata) { //... }
do not use
@formparam
, set string.@formparam
requirescontent-type: application/x-www-form-urlencoded
use
@consumes(value={"application/vnd.api+json",mediatype.application_json})
this worked us.
Comments
Post a Comment