on 01-16-2020 9:32 AM
Hello everybody,
I want to use OCR to recognize text from a file or image in RPA.
In the added custom task, the Call for OCR Service API was created, but I cannot understand how I can upload the file for this request (ctx.ajax.call).
I want to add it to the "data" parameter.
1.
var model = {
lang: "en, de",
outputType: "txt",
pageSegMode: "1",
modelType: "lstmStandard",
files: "C: .... \ Screenshot_1.png"};
ctx.ajax.call({...
data: model,
...});
But when I add it to json, I get an error and the OCR service cannot find the “files” parameter.
2.
var form = new FormData ();
form.append ("files", "/C:....Screenshot_1.png");
ctx.ajax.call({...
data: form,
...});
When I add it to “FormData” (as in the Doku API from api.sap.com), this is impossible (the error is “ErrorType FormData not defined”).
Kindly help or suggest.
Hi,
To upload a file, you can use the following example :
ctx.ajax.call({
url: 'https://...',
method: e.ajax.method.post,
formData: {
name: 'files', file: 'C:\\Temp\\Capture.png'
},
contentType: e.ajax.content.form,
success: function(res, status, xhr) {
sc.endStep(); // Custom
return;
},
error: function(res, status, xhr) {
ctx.log(' ctx.ajax.call error: ' + res);
rootData.MyData.content = res;
}
});
You will need to adapt it to the service you want to use.
Regards,
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
11 | |
10 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.