I'm trying to semd a base64 encoded fimage to the ocr.space api following https://ocr.space/blog/2016/10/ocr-api-supports-base64.html and https://ocr.space/ocrapi . You can see my Postman settings in the screenshot.
However when I submit it I see:
"ErrorDetails": "Not a valid base64 image. The accepted base64 image format is 'data:<content_type>;base64,<base64_image_content>'. Where 'content_type' like 'image/png' or 'image/jpg' or 'application/pdf' or any other supported type.",
Using Postman I have created the following curl request https://pastebin.com/ajfC3a5r
What am I doing wrong
How about this modification?
\n
is included.\n
was removed from the base64 data, it was found that the data was PDF file. The content type was not image/png
.By these, I think that the error which was shown at your question occurs. So please modify as follows.
\n
from the base64 data.data:image/png;base64,##### base64 data #####
to data:application/pdf;base64,##### base64 data #####
.When above modifications were done, how about using the following curl command?
curl -X POST \
https://api.ocr.space/parse/image \
-H "apikey:#####" \
-F "language=eng" \
-F "isOverlayRequired=false" \
-F "iscreatesearchablepdf=false" \
-F "issearchablepdfhidetextlayer=false" \
-F "base64Image=data:application/pdf;base64,##### base64 data #####"
When above sample is run, the following value is returned.
{
"ParsedResults": [
{
"TextOverlay": {
"Lines": [],
"HasOverlay": false,
"Message": "Text overlay is not provided as it is not requested"
},
"TextOrientation": "0",
"FileParseExitCode": 1,
"ParsedText": "##### text data #####",
"ErrorMessage": "",
"ErrorDetails": ""
}
],
"OCRExitCode": 1,
"IsErroredOnProcessing": false,
"ProcessingTimeInMilliseconds": "123",
"SearchablePDFURL": "Searchable PDF not generated as it was not requested."
}
In my environment, I could confirm that the API worked using above modified base64 data and sample curl.
Or you can also directly use the image file which is not base64 data. The sample curl is
curl -X POST https://api.ocr.space/parse/image -H "apikey:#####" -F "[email protected]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With