Open jmcx opened 11 years ago
For such processing, you can throw a Restlet ResourceException within your server resources, as described below :
@Post
public Contact addContact(Contact contact) {
if (contactExists(contact)) {
throw new ResourceException(Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY);
}
}
Note that the Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY corresponds the 422 status code.
The server may return an error if the contact being created already exists. The client must integrate this response and inform the user.