Hi
I'm getting unsupported file format (551 status code) error, can you look into the code and let me know if this is correct.
StaticResource sr = [SELECT Id, name, Body FROM StaticResource where name = 'TESTING' LIMIT 1];
String b64String = EncodingUtil.base64Encode(sr.Body);
String hexString = EncodingUtil.convertToHex(sr.Body);
system.debug('\n= '+b64String +'\n hex= '+hexString);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setMethod('POST');
request.setEndpoint('https://cloud.ocrsdk.com/processimage?language=english&profile=documentconversion&exportformat=pdfSearchable');
Blob headerValue = Blob.valueOf(''+':'+'');
String authorizationHeader = EncodingUtil.base64Encode(headerValue);
request.setHeader('Authorization', 'Basic ' + authorizationHeader);
request.setBody(hexString);
HttpResponse response = http.send(request);
system.debug('\nponse = ' + response.getBody());
コメント
2件のコメント
Hi,
Can you please confrim if base64Encode is supported?
Hi,
Indeed, one of possible reason of this error could be incorrectly formed request body. Please make sure that you transmit the binary data as is to the service. The fact is that Cloud OCR SDK cannot work with data encoded in base64. Please see how the requests to the service are formed in our code samples in different programming languages.
Also such error can happen when you try to process an image located on a remote server. Please note that all actual processing methods are suitable only for the images that are loaded from the computer directly.
And if the issue persists, please send us the logs from any HTTP debugger (for example, Fiddler). It allows to see what requests do you send to the server. You can download the Fiddler debugger for free here: www.telerik.com/fiddler.
サインインしてコメントを残してください。