Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring RestTemplate POST method without body

I am trying to write a client in which I will do the POST method without body. Is the only solution to insert null? example:

client.exchange("/" + userId + "/logout", HttpMethod.POST, null, String.class);
like image 467
sicio Avatar asked Jun 11 '26 01:06

sicio


1 Answers

You can also pass HttpEntity.EMPTY (or new HttpEntity<>(null)) there - the result should be the same.

If you have HttpHeaders object - you can also pass it into the corresponding constructor: new HttpEntity<>(httpHeaders)

like image 53
amseager Avatar answered Jun 13 '26 07:06

amseager



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!