Reputation: 277
I am exposing a REST service in which i'm trying to return different HTTP status codes based on the type of error.
Unfortunately the only error status that I managed to send is 500.
I tried the following but it doesn't seem to work.
throw new RestException(e.getMessage(), ServletUtil.getCurrentResponse().getResponse(), 404);
Any ideas?
Thank you in advance.
Upvotes: 0
Views: 529
Reputation: 960
For ATG 11.3 you have different types of RESTful web services:
If you are using the JAX-RS web services then follow the instructions here
In addition the API Documentation states the following:
Note that all RestExceptions require that a servlet response status code be supplied in order to appropriately set the status on the response object. The error code must be an http status code from the HttpServletResponse object
Also note, there are two RestException classes one is atg.rest.RestException
and the other is atg.service.jaxrs.RestException
so make sure that you have imported the right one.
If you are using REST MVC (which I am guessing your are) then follow the instructions here.
Upvotes: 1