-
Notifications
You must be signed in to change notification settings - Fork 38.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid default Accept header from HttpUrlConnection in RestTemplate with put and delete #23740
Comments
Hmmm... can this have something to do with it?
Spring 5.1 is Java 8 and later, so this code should be deleted anyways i guess? |
@nytro77 this sounds more like server-side behavior. |
Ok, so i guess the error is in Spring Boot then? Or somewhere else in the Spring code? I have configured nothing at all in the Spring Boot project that reproduces the problem. Just a simple
I tried with boot 2.2.0.RC1 and the result is the same. |
I booted the application and called GET and DELETE for http://localhost:8080/test using curl.
So i guess that there must be something strange with the RestTemplate after all? |
It looks like this is due to For |
Affects: 5.1.10
It seems that the RestTemplate does not handle exceptions thrown by DELETE the same way as it does for GET and POST.
HttpStatusCodeException.getResponseBodyAsString()
returns whitelabel error page as HTML instead of the expected JSON.Example from exceptional DELETE:
<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Tue Oct 01 15:38:04 CEST 2019</div><div>There was an unexpected error (type=Internal Server Error, status=500).</div><div>I am delete error</div></body></html>
Example from exceptional GET:
{"timestamp":"2019-10-01T13:38:04.682+0000","status":500,"error":"Internal Server Error","message":"I am get error","path":"/test"}
Reproduced in this simple Spring Boot project
The text was updated successfully, but these errors were encountered: