I have an end point of HTTP DELETE
method.
I want to pass some headers, more specifically Content-Type=application/x-www-form-urlencoded
.
Also there are some parameters based on which at server side it will be decided which record should be deleted. And Server Implementation is not accessible to me.
I am using apache HTTP client. My method for HTTP DELETE is as follow :
private String doDelete(String url, Map<String,String> params, Map<String,String> headerMap){
HttpClient httpClient = new DefaultHttpClient(httpParams);
HttpDelete httpDelete = new HttpDelete(httpRequestWrapper.getUrl());
if(headerMap != null){
for(String headerName : headerMap.keySet()){
httpDelete.addHeader(headerName, headerMap.get(headerName));
}
}
if(params != null){
for(String paramName : params.keySet()){
httpParams.setParameter(paramName, params.get(paramName));
}
httpDelete.setParams(httpParams);
}
HttpResponse httpResponse = httpClient.execute(httpDelete);
HttpEntity httpEntity = httpResponse.getEntity();
String responseStr = getASCIIContentFromEntity(httpEntity);
return responseStr;
}
The problem is, I am seeing (In Debug Mode) that parameters are correctly being passed in delete request from my end. But at server end parameters are received blank. Is there any way I can pass parameters & headers successfully?
Any help is appreciated.