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());

asked 06 Jan, 12:30

a_piyush's gravatar image

a_piyush
112

edited 08 Jan, 19:38

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

(09 Jan, 13:18) Oksana Serdyuk ♦♦
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×11
×1
×1

Asked: 06 Jan, 12:30

Seen: 165 times

Last updated: 09 Jan, 13:18

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal