Unsupported image file format!

  • 189 Views
  • Last Post 09 January 2017
a_piyush posted this 06 January 2017

Getting error: Unsupported image file format...Posting the code...Kindly Help!

String url = 'http://cloud.ocrsdk.com/processImage?language=english&exportformat=pdfSearchable';

String appId='';
String pwd='';
String toEncode=appId+':' + pwd;
Blob beforeblob = Blob.valueOf(toEncode);
string paramvalue = EncodingUtil.base64Encode(beforeblob);
Attachment att = new Attachment();
att = [SELECT ID,Body,ContentType FROM Attachment where ContentType='image/jpeg' and ID='00P2800000KuwQf' LIMIT 1];
String strImg=EncodingUtil.base64Encode(att.body);

        Http h = new Http();
        HttpRequest req = new HttpRequest();

        req.setEndpoint(url);
        req.setMethod('POST');
        req.setHeader( 'Authorization', 'Basic ' + paramvalue);
        req.setHeader('Content-Type', 'image/jpeg');
        req.setBody(imgBlob);
        req.setBody(strImg);        
        req.setHeader('Content-Length', String.valueOf(strImg.length()));
        HTTPResponse res = h.send(req);
        System.debug(res.getBody());

Oksana Serdyuk posted this 09 January 2017

I have sent you some general recommendations concerning this issue to your email.

Close