When the RestApi has ResponseEntity<void> of spring has return value it returns ClientProtocolException
<p>I have a RestApi exposed which on case returns status ok back to client.
The method signature of the method is <code>ResponseEntity&lt;void&gt; methodName(){}</code>.
This method is a deleteApi.</p>
<p>In the return <code>responseEntity</code> is created with just <code>Status OK</code> and no body or any other header details are appended.</p>
<p>Seen in the logs that I get <code>ClientProtocolException</code> when the call is made , saw that when the same is executed through the REST client (postman) received correct <code>Status OK</code> message in the response.</p>
<ul>
<li><p>What are the reasons when the <code>ClientProtocolException</code> is raised?</p>
</li>
<li><p>If the return type is <code>ResponeEntity&lt;Void&gt;</code> is it mandatory to send body with it ?</p>
</li>
<li><p>How do i avoid getting the above exception?</p>
</li>
</ul>
<p>Code:</p>
<pre><code> @RequestMapping(method = RequestMethod.DELETE)
public ResponseEntity&lt;Void&gt; methodName()
{
   // your business logic 
    return new ResponseEntity&lt;Void&gt;(HttpStatus.OK);
}
</code></pre>