function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dev app 1dev app 1 

http callout error

Hi,
 
I am trying to make HTTP callout To Abbyy cloud(https://cloud.ocrsdk.com/processBusinessCard) , I am getting the below error: Unsupported image file format.
 
Please find the code below:
 
 
      String endPointURL = 'https://cloud.ocrsdk.com/processBusinessCard';
      String userName = '';
      String password = '';
      ContentVersion co = [Select id,pathOnClient,title,versionData  from ContentVersion ];
     String afterblob = EncodingUtil.base64Encode(co.versionData);
   
      Blob headerValue = Blob.valueOf(userName + ':' + password);
      String authorizationHeader = 'BASIC ' +
      EncodingUtil.base64Encode(headerValue);
 
      Httprequest request = new HttpRequest();
      Http http = new Http();
 
          request.setMethod('POST');
          request.setEndpoint(endPointURL);
       request.setHeader('Authorization', authorizationHeader);
        request.setBody(afterblob);         
         
          //Making call to external REST API
          HttpResponse response = http.send(request); 
 
          System.debug('responseBody: '+response.getBody());
 
I need to send the image as request body, but the image is stored base 64 format in content version object in version data field.
 
Can anyone help me how to pass the image as request body in the above call out.
 
 Thanks,
Mahesh.