I'm trying to use the Spring endpoints to gracefully shut down my application but I'm getting an error:
2016-08-09 13:46:54.606 WARN 13315 --- [nio-8090-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Handler execution resulted in exception: Request method 'POST' not supported
I'm using this guide and I've set my application.properties to have endpoints.shutdown.enabled=true and also endpoints.shutdown.sensitive=false. I've also included compile("org.springframework.boot:spring-boot-starter-actuator") in my build.gradle.
When I send the CURL request: curl -X POST https://localhost:8090/shutdown -k
I get the following response from the server:
{"timestamp":1470747537792,"status":405,"error":"Method Not Allowed","exception":"org.springframework.web.HttpRequestMethodNotSupportedException","message":"Request method 'POST' not supported","path":"/shutdown"}
Am I doing anything incorrectly? Is there anything that I may be missing? I have CSRF enabled throughout the app so it's not an option to disable that for my application.
You need to send a CSRF token either as a header or a parameter or something. Your example:
curl -X POST https://localhost:8090/shutdown -k
does not include a CSRF token so of course Spring will reject it. That is indeed the whole point of the CSRF filter. You will need to decide whether it is appropriate to exclude the /shutdown uri from that filter or whether you want to require a token/nonce to be present.
I'am using Springboot-1.5.3-RELEASE, use http method POST (not GET)。 It works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With