Checks the status of a file. It is recommended to wait at least 2 seconds between Query calls. Calling the Query method more frequently than this will not have any impact on application performance. The method can be called with a Post or Get request to the following URL:
[POST][GET] https://azure.leadtools.com/api/Query
Additional parameters available are listed below.
Parameter | Description | Accepted Values |
---|---|---|
id |
Unique identifier corresponding to an uploaded file. | A valid GUID |
The following status codes will be returned when the method is called:
Status | Description |
---|---|
200 | The Query request completed successfully |
400 | The request was not valid for one of the following reasons: • Invalid GUID was provided |
401 | The AppID/Password combination is not valid, or does not correspond with the GUID provided. |
500 | There was an internal error processing your request. |
A successful request will return a JSON Object with the following format:
{
"FileStatus":,
"RequestData": [
]
}
The RequestData
property will be empty unless the File Status value is 200. The possible File Statuses are as follows:
File Status | Description |
---|---|
100 | The file is currently being processed. |
122 | The file hasn't been set to run. This is for files that have been uploaded via the UploadFile API call and haven't had the Run method called on them. |
123 | The file is currently undergoing verification. This is for files that have been recently uploaded via the UploadFile API call, or from one of the single service Conversion/Recognition calls. If the UploadFile API method was called originally, the file's worker status will be set to 122 after the verification process completes successfully. If one of the Recognition/Conversion single service API methods were called, then the file's worker status will be set to 100 and processing will begin on the file. |
200 | The file has finished processing successfully. The RequestData property will contain a serialized list of all the pertinent information for the request(s) that were made against the file. For the JSON structure for the different request objects, refer to the Common Request Parameters and Return Objects section |
500 | There was an internal error processing the file. |
501 | The file has been deleted. Files/data will be deleted automatically after 24 hours, or if the DeleteRequest API method is called. |
502 | The file has been rejected. Files will be rejected if they fail the verification process. Rejected files will be deleted automatically after 24 hours, or if the DeleteRequest API method is |
600 | Processing of the file has been aborted because there are not enough pages remaining in the application. |
//This sample uses the Request NodeJs library.
const request = require('request');
var servicesUrl = "https://azure.leadtools.com/api/";
var requestID = '00000000-0000-0000-0000-000000000000';
function queryServices(requestID){
//Function to query the status of a request. If the request has not yet finished, this function will recursively call itself until the file has finished.
var queryUrl = servicesUrl +"Query?id=" + requestID;
request.post(getRequestOptions(queryUrl), async function (error, response, body){
var results = JSON.parse(body);
if(!error && results['FileStatus']!=100 && results['FileStatus']!=123){
console.log("File finished processing with return code: " + response.statusCode);
if(results['FileStatus']!=200){
return;
}
console.log("Results: \n");
console.log(results['RequestData']);
}else{
//The file has not yet finished processing.
await function(){
return new Promise(resolve=> setTimeout(resolve, 5000)); //Sleep for 5 seconds before trying again
}
queryServices(requestID); //Call the method again.
}
});
}
function getRequestOptions(url){
//Function to generate and return HTTP request options.
var requestOptions ={
url: url,
headers: {
'Content-Length' : 0
},
auth: {
user:"Enter Application ID",
password:"Enter Application Password"
}
};
return requestOptions;
}