Reputation: 61
I'm pretty new with Java REST, I'm currently confused with the response I'm getting from POSTMAN or Chrome is always defaulted to XML and could not change it to JSON unless I remove the XML part. I'm using Jersey 2, Netbeans and Glassfish 4.1.1/4.1
This only returns XML
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
This will return JSON only
@GET
@Path("loc/{lat}/{long}")
@Produces({MediaType.APPLICATION_JSON})
@SuppressWarnings("unchecked")
//@Produces({MediaType.TEXT_PLAIN})
public List<Lastknown> findNearMeLastKnown(@PathParam("lat") String lat, @PathParam("long") String longitude) {
//List<Lastknown> results =;
return super.findNearMeLastKnown(lat,longitude);
}
Upvotes: 3
Views: 4777
Reputation: 13857
A quick guess, you have to add the following header in POSTMAN:
Accept: application/json
Otherwise the server doesn't know which format you want....
Upvotes: 8