I have a Jersey REST implementation that provides an API from Tomcat (Server1)
@POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Users create(Users users) { return dao.create(users); }
and the request is sent from the jQuery client from Apache (Server2)
$.ajax({ type: 'POST', contentType: 'application/json', url: rootURL, dataType: "json", data: formToJSON(), success: function(data, textStatus, jqXHR){ alert('user created successfully'); }, error: function(jqXHR, textStatus, errorThrown){ alert('user error: ' + textStatus); } });
This jquery actually sends the request to the server, but the server / API was not able to recognize this request. All other queries like @ Formparam / @ Header etc. also work. with POST / GET.
If I use the same thing using the REST client, it worked, can someone help me sort this problem for POST with the request type Object.
source share