I would like to send this JSON message below, with the HTTP DELETE method. For this project is necessary to use OAuth2. So I use the dependency google-oauth. Foreach HTTP request I use the dependency google client.
{
"propertie" : true/false,
"members" : [
"String value is shown here"
]
}
In my project I used this code below, but I cannot send the JSON message with the HTTP DELETE method.
Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
JsonArray members = new JsonArray();
JsonPrimitive element = new JsonPrimitive("String value is shown here");
members.add(element);
JsonObject closeGroupchat = new JsonObject();
closeGroupchat.addProperty("propertie", false);
closeGroupchat.add("members", members);
Gson gson = new Gson();
HttpContent hc = new ByteArrayContent("application/json", gson.toJson(closeGroupchat).getBytes());
HttpRequestFactory requestFactory = httpTransport.createRequestFactory(credential);
HttpRequest httpreq = requestFactory.buildRequest(HttpMethods.DELETE, genericUrl, hc);
return httpreq.execute();
Next error occurs:
java.lang.IllegalArgumentException: DELETE with non-zero content length is not supported
Can someone help me with this problem?