I would like to send a 201 HTTP response after a resource is created along with its location.
HTTP/1.1 201 Created
Location: http://www.example.org/myresource/12546
How do you define your @ApiMethod
?
As stated in the Documentation:
HTTP 200 is typically assumed by Endpoints if the API method returns successfully. If the API method response type is void or the return value of the API method is null , HTTP 204 will be set instead. HTTP 2xx codes should not be used in custom exception classes.
having said that if you still need to return a 201 code, you can hack a service exception to provide that.
public class EverythingOKException extends ServiceException {
public EverythingOKException(String message) {
super(201, message);
}
}