How can I create a dropwizard (jersey) resource which accepts a nullable representation? -
i trying create action on resource within dropwizard accepts representation, allows null, ie. no post data client.
currently, client, have post "{}" otherwise http 415, unsupported media type returned. assume because client not sending content-type header content-length = 0.
i tried define resources follows, "producing media type conflict" jersey both methods consume same path , jersey cannot differentiate between them:
@path("/interview") @produces(mediatype.application_json) @consumes(mediatype.application_json) @log class interviewresource { @post @timed interview advancenewinterview() { // processing... } @post @timed enquiry advancenewinterview(@valid advanceinterviewrepresentation advanceinterview) { // processing... } }
any ideas on how represent this?
you use optional parameter show below:
@post @timed enquiry advancenewinterview(@valid optional<advanceinterviewrepresentation> advanceinterview) { if (advanceinterview.ispresent()) { // processing... } }
howerver main reason 415 not mentioning content-type header. in case should content-type : application/json
Comments
Post a Comment