When I use the API with a url it works perfect, but if I do it > with a file, I don't get it to work

When I use the API with a url it works perfect, but if I do it with a file, I don’t get it to work. This is the code I use:
var xhr =new XMLHttpRequest(); xhr.withCredentials = true;
xhr.open(“POST”, url,false);
xhr.setRequestHeader(“Content-Type”,“application/x-www-form-urlencoded”);
xhr.setRequestHeader(“cache-control”, “no-cache”);
xhr.send(data);

where data=
apikey=mi_api_key&file=mi_file.pdf&language=spa&isOverlayRequired=false;

The response is:
{“OCRExitCode”:99,“IsErroredOnProcessing”:true,“ErrorMessage”:[“Parameter name ‘file’ is invalid. Valid parameters: apikey,url,language,isoverlayrequired,base64image,iscreatesearchablepdf,issearchablepdfhidetextlayer,filetype,addressparsing,scale,detectorientation,istable,ocrengine,detectcheckbox,checkboxtemplate,checkboxtemplateregex”,“Please check if you need to URL encode the URL passed in request parameters.”],“ProcessingTimeInMilliseconds”:“0”}

Thanks a lot!

“file” is a valid parameter but it can not be used with GET calls (Get calls are when you use a URL in the browser to call the API):

https://ocr.space/ocrapi#get

only with POST calls (= submit data):

https://ocr.space/ocrapi#PostParameters

Solution: With GET calls, use the url parameter and send link to the file you want to ocr (as you did first)

Hi Ulrich
If you look, I use the post method and it is not launched from the browser, but from a desktop application.
Thanks

Hi, try my solution here;

POST pdf document.

Thanks,
Zabir.