Status=Length Required, StatusCode=411 error in Apex callout

Status=Length Required, StatusCode=411 error in Apex callout

Content-Length should be mentioned to avoid this error in callouts.

Sample Code:

HttpRequest request = new HttpRequest();  
request.setHeader(
	'Content-Length', 
	'512'
);  

Use GET method instead of POST method. So that, Content-Length is not required. If you use POST method, Content-Length is required.

Leave a Reply