+ Start a Discussion
Luis MatosLuis Matos 

POST Method error 411

     public static void  makePostCallout(String jbody) {
         //STring jbody = json.serialize(accs.Value);
            System.debug('OLHA O BODY:::::' + jbody);
            String ep = 'link to endpoint';
            HttpClient httpObj = new HttpClient('client and pass here');  // Note two forward slashes between domain and username \\  /
//HttpRequest req = new HttpRequest();
           // Http x = new Http();
            HttpRequest response = new HttpRequest();
            response.setHeader('Content-Type', 'application/soap+xml;charset=UTF-8');

            response.setHeader('Content-Length', '512');
            System.debug('OLHA O BODYAGORA :::::' + response.getBody());
            HttpResponse res2 = httpobj.send(response);
            system.debug('RESPOSTA DO FUTURE::::::::' + res2.getbody());

This code when trying to post updates to server keeps giving me the error 411 like this :
16:18:13:000 USER_DEBUG <HTML><HEAD><TITLE>Length Required</TITLE>
16:18:13:000 USER_DEBUG <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
16:18:13:000 USER_DEBUG <BODY><h2>Length Required</h2>
16:18:13:000 USER_DEBUG <hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
16:18:13:000 USER_DEBUG </BODY></HTML>

Am I doing something wrong???
I would try removing the setCompressed first.  I have found that sometimes this screws with POST requests.
Srinath R 9Srinath R 9
How were you able to resolve this error? I am facing a similar error when making a POST request from Salesforce.