I am implementing a simple rest service with the 4 http methods get,post, put and delete using sitebricks. trying to send a delete request to the defined service with a WebClient I get a 405 response. Does anyone knows why would I get such response ?
10:22:24.840 [5907955@qtp-6711891-2 - /r/clients/123] DEBUG org.mortbay.log - RESPONSE /r/clients/123 405
This is how I use web client
WebClient client = web().clientOf(delete(123)).transports(String.class).over(Json.class);
client.delete();
here is my delete method
@Delete
@At("/:id")
public Reply delete(@Named("id") String id) {
clientsRepository.delete(id);
return Reply.saying().ok();
}
I am using Jetty Server.
Response code 405 means that something is configured to not allow the use of the http DELETE method.
I can't speak for sitebricks itself, but servlet spec allows you to disable specific methods.
The
web.xmlof your webapp or the${jetty.home}/etc/webdefault.xml, as either could be configured to disallow the use of specific HTTP methods (like TRACE, PUT, DELETE).Check those files for
<security-constraints>that might have<http-method>declarations for DELETE.Also note that any code can trigger the 405 response itself. Since you are seeing this in Sitebricks, possibly a
<filter>in your web.xml is preventing it.