URL for local files

Hi Everyone,

Recently i joined this forum, I want to extract JSON text from a PDF file via Free OCR API. How to specify URL for local files (Drive C: D: …)?
I experimented via Postman (GET) but without success

Thanks,
Miloslav

For local files you can not use the GET method. The GET method works only if you have uploaded the PDF somewhere, and you have a URL to it.

=> Use the POST method.

Many thanks, I have got message for POST https://api.ocr.space/parse/imageurl?apikey=myAPIkey
saying
“The requested resource doesnt support http method ‘POST’”, even when I use url=http://xxxx"
Can I get JSON text from local PDF file using this Free OCR API? Please advice
BRGS Miloslav

If it’s a local file and using POST then it wouldn’t be a URL, it would be your path.

https://ocr.space/OCRAPI

Many thanks to all,
I have succeeded POST in Postman, working :grinning: :grinning:
Now I am fighting with WinHTTPRequest string, ResponseStatus is 200-OK,but filetype (pdf in my case) is not recognized - “Unable to recognize the file type”
.SetRequestHeader “Content-type”, “multipart/form-data”
.SetRequestHeader “filetype”, “pdf”
.SetRequestHeader “language”, “cze”
.SetRequestHeader “file”, “@/D:/SV/xxx.pdf”
Many thanks for advice, if possible…
M.

What scripting language do you use?

Hi Admin, thanks
Microsoft Access VBA (reference MS WinHTTPServices 5.1)
Call:
Set objOCRHTTP = New WinHttpRequest
With objOCRHTTP
.Open “POST”, “https://api.ocr.space/parse/image”, False ‘’ & “?filetype=pdf”, False
.SetRequestHeader “apiKey”, “myAPIKeyxx”
.SetRequestHeader “Content-type”, “multipart/form-data”
.SetRequestHeader “filetype”, “pdf”
.SetRequestHeader “language”, “cze”
.SetRequestHeader “file”, “@/D:/SVJ/MyPDFFile.pdf”
.SetRequestHeader “iscreatesearchablepdf”, False
.SetRequestHeader “issearchablepdfhidetextlayer”, False
.SetRequestHeader “iscreatesearchablepdf”, False
.SetRequestHeader “istable”, True
.Send
response=.ResponseText
end with
I also tried combination
.SetRequestHeader “filetype”, “pdf” and
& “?filetype=pdf” in POST string
Thanks again
Miloslav

This issue is fixed now. Please see OCR API filetype not detected

Dear Admin
Unable to Recognize the File Type message continues
Dim objOCRHTTP As New WinHttp.WinHttpRequest
With objOCRHTTP
.Open “POST”, “https://api.ocr.space/parse/image”, False
.SetRequestHeader “apiKey”, “MyAPIKeyString”
.SetRequestHeader “content-type”, “application/pdf”
.SetRequestHeader “language”, “cze”
.SetRequestHeader “file”, “/D:/SVJ/2020/2020FakturySVJ/Akus2019.pdf”
.Send
PoleTemp = .ResponseText
If .Status <> 200 Then
MsgBox .Status & " - " & .StatusText
End If
MsgBox PoleTemp
End With
Result:
Status=200
OCR Response :
{“OCRExitCode”:99,“IsErroredOnProcessing”:true,“ErrorMessage”:[“Unable to recognize the file type”],“ProcessingTimeInMilliseconds”:“0”}
Experiencing with
.SetRequestHeader “filetype”, “PDF” has no effect

PostMan result is OK
image
BRGS
Miloslav

So everything works when called with Postman?

Hi Admin, many thanks for your response
“So everything works when called with Postman?”
That is the correct question.
If I specify parameters under Body, everything is OK.
I tried to specify them under Params only (+ Authorisation ApiKey) and it is not working :hushed:, I have got the same message “Unable to recognize the file type”, see picture below.
The issue is if api.ocr.space…is able to accept this type of request.
In my WinHTTP I have only one option= SetRequestHeader, no option like …Body


Best regards
Miloslav