Open olivermt opened 9 years ago
I ran into this same issue.
As a workaround for this:
public class CustomRESTClient extends RESTClient {
private static class HttpDeleteWithEntity extends HttpEntityEnclosingRequestBase {
public final static String METHOD_NAME = "DELETE";
@Override
public String getMethod() {
return METHOD_NAME;
}
}
public CustomRESTClient(Object defaultURI) throws URISyntaxException {
super(defaultURI);
}
@Override
public Object delete(Map<String,?> args) throws URISyntaxException, ClientProtocolException, IOException {
return doRequest(new RequestConfigDelegate(args, new HttpDeleteWithEntity(), null));
}
}
@jonpeterson I did as you have mentioned here, but for whatever reason the overridden delete method is not getting called & I still keep getting the error.
import groovyx.net.http.Method;
import groovyx.net.http.RESTClient;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;
public class RichRESTClient extends RESTClient {
private static class HttpDeleteWithEntity extends HttpEntityEnclosingRequestBase {
@Override
public String getMethod() {
return Method.DELETE.name();
}
}
public RichRESTClient(Object defaultURI) throws URISyntaxException {
super(defaultURI);
}
@Override
public Object delete(Map<String, ?> args) throws URISyntaxException, IOException {
return this.doRequest(new RequestConfigDelegate(args, new HttpDeleteWithEntity(), null));
}
}
@tankchintan, do you use then RichRESTClient instead of RESTClient? That solution help me.
In case if somebody's still having this issue, the more compact solution is:
RESTClient.metaClass.delete = { Map<String,?> args ->
def deleteRequestWithEntity = [getMethod: { "DELETE" }] as HttpEntityEnclosingRequestBase
delegate.doRequest(new RequestConfigDelegate(delegate, args, deleteRequestWithEntity, null));
}
@rtretyak Thanks for your compact solution. very helpful.
Groovyc: unable to resolve class RequestConfigDelegate I am getting this error when I try to use this. RequestConfigDelegate is protected inner class Any suggestions on how to get it working.
@arpithavaddu
Are you missing the import statement? import groovyx.net.http.HTTPBuilder.RequestConfigDelegate
http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request
There is nothing in the spec that says this is disallowed.
Is there any particular reason that this is not implemented?