Skip to content

Spring 3.5.3 sending request body in DELETE request #46581

@danielvolovik96

Description

@danielvolovik96

Hey, after updating our micro-service that used Spring 3.5.0 to Spring 3.5.3 sending DELETE requests with bodies has stopped working. The service on the receiving end is receiving the request without the body. The only change between the scenarios is the Spring version on the service that sent the request.
The code for sending the request:

    protected <T, K> boolean sendDeleteRequest(String url, T requestBody, ParameterizedTypeReference<K> responseType) {
        boolean retVal = false;

        HttpEntity<T> httpEntity = new HttpEntity<>(requestBody);

        try {
            ResponseEntity<K> result = restTemplate.exchange(
                    url,
                    HttpMethod.DELETE,
                    httpEntity,
                    responseType
            );

            if (result.getStatusCode().is2xxSuccessful()) {
                log.debug("Successfully sent DELETE request to: {}", url);
                retVal = true;
            } else {
                String errorMessage = String.format("Error while sending DELETE request to: %s, response: %s",
                        url, result.getStatusCode());
                log.error(errorMessage);
            }
        } catch (Exception ex) {
            log.error("Error while sending DELETE request to: {}", url, ex);
        }

        return retVal;
    }

Where restTemplate is: org.springframework.web.client.RestTemplate.

Has something changed between 3.5.0 to 3.5.3 in that sense? I haven't noticed this in the changelog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: duplicateA duplicate of another issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions