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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -