OCR APi on SoapUI


#1

HI All,
I’m trying to use the API Post https://api.ocr.space//parse/image (with base64) on Soapui and not able to.
This is the structure that I’m using:
header:
apikey: xxxxxxxxxx
language: english
Body:
{
“base64Image”:“iVBORw…”
}
i’m getting "No file uploaded or URL or base64 provided"
Where do I do it wrong?
Please advice.
Thanks,
Lior grinberg


#2

Personally I have no experience with SoupUI for api testing, as we use Postman for our internal QA.

So as a first test, if you test the base64 sending with Postman, do you get the same result?

You probably know it, but just in case: Postman is a free Chrome/Win/Mac app, see https://ocr.space/ocrapi#postman

If you see the problem even with Postman, a screenshot of the result could be helpful.


#3

Thanks for the answer.
In postman it does work but my problem is that I need the request structure.
I’m working on service now application and in there I need to give it the body structure. The header I know.
And in soapui I can see the structure.
So can anyone provide to me the correct structure?
Thanks,
Lior grinberg


#4

I guess I don’t understand what you mean by “request structure”.

That said, we can of course create a sample for SoapUI, but it will take a few days (we are quite busy right now).


#5

I will really appreciate if you build an example in Soapui.
Thank you very much.
Lior grinberg


#6

Hi liorg,

here is a sample I extracted from a successfull Postman call.
I changed the end of the apikey and shorten the file content in code bellow.

I hope this can help you !

POST /parse/image HTTP/1.1
Host: api.ocr.space
Cache-Control: no-cache
Postman-Token: 9ab96540-2a23-9ae0-af00-9a56d1828e9f
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“apikey”

987479216988[XYZ]
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“language”

fre
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“isCreateSearchablePdf”

True
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“isOverlayRequired”

False
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=“base64image”

data:image/jpeg;base64,/9j/4AAQSkZJRgABAAEAY[…]

------WebKitFormBoundary7MA4YWxkTrZu0gW–


#7

Hi Lior,

Did you get this to work in SNow? I have been playing around with this API and could not get it to work in SNow… I’m getting the “ocrExistCode: 99 IsError: true ErrorMessage: No file uploaded or URL or base64 provided”… I see in your example you maybe missing the Prefix stuff in the Base64 String… data:image/png;base64,[binary data]…

Does anyone else know of any other OCR APIs that provide base64 uploads?

Here is my code…

    request = new sn_ws.RESTMessageV2();
request.setHttpMethod('POST');
request.setRequestHeader('apikey','xxxxxxxxxxxxxxxx');

request.setEndpoint('https://api.ocr.space/parse/image');
	
	
var requestBody = {}, b64image;
		
var StringUtil = new GlideStringUtil();
var sa = new GlideSysAttachment();
		
	
    var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.get('66256e44dbc277002bf25901cf961962');

var binData = sa.getBytes(attachmentGR);
var encData = StringUtil.base64Encode(binData);
var obj ={};
			
b64image = 'data:image/'+fileType+';base64,'+encData;
			
gs.log(b64image);

request.setRequestBody('base64Image',b64image);

var response = request.execute();