Jax-RS: Send an empty JSON for void methods

A restful resource’s method can be void. In this case, what should be sent to the client side in terms of http response body ?

According to my experience, you must send an emtpy JSON or an empty XML depending on the content type, instead of sending nothing. In the latter case, some clients may mistakenly consider it as invalid format.

Do this:

return Response.ok("{}").build(); 

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.