You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend the rest api with a new optional query param 'format' to allow optional force output in XML or JSON. Currenty we only support the header param 'accept'
Using this param we can switch the ouput format:
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response service(@QueryParam("format") String format) {
return Response
// Set the status and Put your entity here.
.ok(entity)
// Add the Content-Type header to tell Jersey which format it should marshall the entity into.
.header(HttpHeaders.CONTENT_TYPE, "json".equals(format) ? MediaType.APPLICATION_JSON : MediaType.APPLICATION_XML)
.build();
}
Extend the rest api with a new optional query param 'format' to allow optional force output in XML or JSON. Currenty we only support the header param 'accept'
Using this param we can switch the ouput format:
See: https://stackoverflow.com/questions/18026296/jersey-how-to-generate-json-and-xml-output-depending-on-url-param/35112400
The text was updated successfully, but these errors were encountered: