• Luis Matos
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Mr
  • Orbcom

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
 @Future(callout=true)
     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.setMethod('POST');
            response.setEndpoint(ep);
            
            response.setbody(jbody);
            response.setHeader('Content-Type', 'application/soap+xml;charset=UTF-8');

            response.setHeader('Accept','application/json');
            response.setHeader('Content-Length', '512');
            response.setHeader('Content-Transfer-Encoding','base64');
            response.setHeader('KeepAlive','true');
             response.setCompressed(true);
             
            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???