How about this modification?
Modification points:
- In your base64 data at here,
\n
is included.
- When I tried to decode the base64 data after
\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.
Modified curl command:
- Please remove
\n
from the base64 data.
- About the header of base64 data, please modify from
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 #####"
Result:
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."
}
Note:
In my environment, I could confirm that the API worked using above modified base64 data and sample curl.
- The curl sample including the modified base64 data is this.
- If you use this, please set your API key.
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 "file=@sample.png"