You need to sign in to do that
Don't have an account?
ShaT
Status=Length Required, StatusCode=411
Hi All,
I spend one day and could not fix this problem. when I run these code below in it throw the error: Status=Length Required, StatusCode=411, Please help me to take a look at it.
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://www.google.com/user/?email=abc@gmail.com');
req.setMethod('POST');
req.setCompressed(true);
req.setHeader('key', '1212113232');
req.setHeader('Content-Type','text/xml');
// req.setHeader('Content-Length', '1');// tired it out with diffrent values but still getting error
System.debug('----------------req-'+req);
HttpResponse res = h.send(req);
System.debug(res.getBody());
Result -
HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
Thanks
Shail
I spend one day and could not fix this problem. when I run these code below in it throw the error: Status=Length Required, StatusCode=411, Please help me to take a look at it.
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://www.google.com/user/?email=abc@gmail.com');
req.setMethod('POST');
req.setCompressed(true);
req.setHeader('key', '1212113232');
req.setHeader('Content-Type','text/xml');
// req.setHeader('Content-Length', '1');// tired it out with diffrent values but still getting error
System.debug('----------------req-'+req);
HttpResponse res = h.send(req);
System.debug(res.getBody());
Result -
HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
Thanks
Shail
Thanks for your response.
I am able to solve th issue. I need to use GET method instead of POST. Than i dont need to give Content-Length.
All Answers
req.setHeader('Content-Length', '4096');
I am getting read time out error.
When i comment it , than its is giving the length error and when i give the length as you have mentioned its gives
05:10:48.711 (10711270549)|FATAL_ERROR|System.CalloutException: Read timed out
Class.RESTClient.CallingGetMethod: line 39, column 1
AnonymousBlock: line 1, column 1
Thanks
ShaT
Can you try sending the request to requestb.in and see if Content Length is getting associated to header or not.If it is,then it's an issue with the end-point I assume.
Hope this helps !!
Thanks for your response.
I am able to solve th issue. I need to use GET method instead of POST. Than i dont need to give Content-Length.