java - "NetworkError: 415 Unsupported Media Type -


i getting networkerror: 415 unsupported media type error when trying hit service. have , let me know wrong.

here rest service definition

@post @produces(mediatype.application_json) @consumes("application/json") @path("/searchpackage") public jsonarray searchpackages(jsonobject obj) throws jsonexception { 

and here jquery client code.

var description=$('#description').val().trim(); var jsonobject= {"searchaction":"search", "description":description); var request = $.ajax({   url: restserviceurl+'searchpackage',   type: 'post',   contenttype: 'application/json',   data: jsondata,   datatype : 'json',   error: function(data) {     console.log(data.responsetext);   } });  

here output appllication.wadl

   <resource path="/searchpackage">     <method id="searchpackages" name="post">     <request><representation mediatype="application/json"/></request>     <response><representation mediatype="application/json"/></response>    </method>   </resource> 

use configuration:

data: json.stringify(jsonobject), contenttype: "application/json", datatype: "json", 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -