Ranjit
Ranjit

Reputation: 13

RestFul webservices Response for Error code

I am working on Restful Web Services which give JSON response and i got following output when there is no data for entered id=11

GET Request Failed Request Failed --> Status: (204) Response: {

}

Now I want That response field contain proper message for error code=204 like "invalid request" or "id doesn't exist"

Upvotes: 1

Views: 953

Answers (1)

TheWhiteRabbit
TheWhiteRabbit

Reputation: 15758

If you are using Jersey or similar JAX-RS framework you can modify your code similar to :

return Response.status(204).type("text/plain")
                .entity("Invalid Request!").build();

Upvotes: 1

Related Questions