Below is an end-to-end example of submitting a request for various methods using Perl programming language:


# Simple script to showcasing how to queue up and run multiple requests using the LEADTOOLS CloudServices.
# In order to run this script, the following changes will need to be added:
#	1) Place your Application ID in the $appId variable.
#	2) Place your Application Password in the $password variable
#
# The script will perform the following operations in order:
#	1)Perform an UploadFile request to the LEADTOOLS CloudServices.  A successfully made request will return a unique identifier.
#    We will use this identifier to queue up further methods. 
#	2)We will queue up an ExtractText method using the identifier that was returned from the UploadFile method. 
#	3)After we verify the ExtractText method was queued, we will then queue up a Conversion method to convert the file to TIFF.
#   4)Once the Conversion request has been queued, we will make a call to the Run method.  This will mark the file as ready to be processed.
#    **Note** Once a file has been marked for processing, or has finished processing, no further requests can be queued or run on that file.
#	5)We will then query the services using the GUID -- if the file is finished processing, the body will contain all the 
#	  request data.
#  6)We will take the json data that was returned, parse it, and display all the information that was returned. 
#
# This script makes use of the following Perl libraries:
#	1) Http-Message - http://search.cpan.org/~oalders/HTTP-Message-6.15/
#	2) libwww-perl  - http://search.cpan.org/~oalders/libwww-perl-6.33/
#	3) JSON-Parse   - http://search.cpan.org/~bkb/JSON-Parse-0.55/
#	4) Try-Tiny     - http://search.cpan.org/~ether/Try-Tiny-0.30/

use base 'HTTP::Message';
use HTTP::Request::Common;
use LWP::UserAgent ();
use JSON::Parse ':all';
use Try::Tiny;


require HTTP::Request;
require HTTP::Headers;

my $servicesUrl = "https://azure.leadtools.com/api/";

#The first page in the file to mark for processing
my $firstPage = 1;

#Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed.
my $lastPage = -1;

#Enum corresponding to the output format for the file. For the purposes of this script, we will be converting to tif.
my $format = 4;

my $appId = 'Replace with Application ID';
my $password = 'Replace with Application Password';

#If uploading via a URL,  the Content_length needs to be set to 0.
#If you are passing a file as multi-part content, the Content_Length does not need to be predefined.
my $headers = HTTP::Headers->new(
    Content_Length => 0
);
$headers->authorization_basic($appId, $password);

#The User Agent to be used when making requests
my $ua = LWP::UserAgent->new;

#We will be uploading the file via a URL.  Files can also be passed by adding a PostFile to the request.  Only 1 file will be accepted per request.
#The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content
my $fileURL = 'https://www.leadtools.com/support/publicforumimages/test/multipage.tif';
my $uploadUrl = $servicesUrl . 'UploadFile?fileurl=' . $fileURL;
my $request = POST $uploadUrl,
   Content =>[];

#If uploading a file as multi-part content:
#my $uploadUrl = $servicesUrl . 'UploadFile';
#my $request = POST $uploadUrl,
#    Content_Type => 'form-data',
#    Content=>[
#        FILE => [ "path/to/input/file" ]
#    ];

$request->authorization_basic($appId, $password);

my $response = $ua->request($request);
if(!$response->is_success){
    print STDERR $response->status_line, "\n";
    exit;
}

my $guid = $response->decoded_content;
print("Unique ID returned by the services: " . $guid . "\n");

my $queryUrl = $servicesUrl . 'Query?id=' . $guid;
while(true){
    $request = HTTP::Request->new(POST => $queryUrl, $headers);
    $response = $ua->request($request);

    $returnedData = parse_json($response->decoded_content);
    if($returnedData->{'FileStatus'} != 123){
        last;
    }
    sleep(5);
}

my $recognitionUrl = $servicesUrl . 'Recognition/ExtractText?firstPage=' . $firstPage . '&lastPage=' . $lastPage . '&guid=' . $guid;
$request = HTTP::Request->new(POST => $recognitionUrl, $headers);
$response = $ua->request($request);
if(!$response->is_success){
    print STDERR $response->status_line, "\n";
    exit;
}
print("Extract Text request successfully queued \n");


my $conversionUrl = $servicesUrl . 'Conversion/Convert?firstPage=' . $firstPage . '&lastPage=' . $lastPage . '&format=' . $format . '&guid=' . $guid;
$request = HTTP::Request->new(POST => $conversionUrl, $headers);
$response = $ua->request($request);
if(!$response->is_success){
    print STDERR $response->status_line, "\n";
    exit;
}
print("Conversion request successfully queued \n");


my $runUrl = $servicesUrl . 'Run?id=' . $guid;
$request = HTTP::Request->new(POST => $runUrl, $headers);
$response = $ua->request($request);
if(!$response->is_success){
    print STDERR $response->status_line, "\n";
    exit;
}
print("File has successfully been marked to run \n");

while(true){
    $request = HTTP::Request->new(POST => $queryUrl, $headers);
    $response = $ua->request($request);

    $returnedData = parse_json($response->decoded_content);
    if($returnedData->{'FileStatus'} != 100){
        last;
    }
    sleep(5);
}

print("File finished processing with file status: " . $returnedData->{'FileStatus'} . "\n");

try{
    # The file did not process successfully.  Refer to our documentation for the full list of File Statuses and their associated meanings.
    if($returnedData->{'FileStatus'} != 200){
        exit;
    }
    print("Results: \n");  
    $parsedResponse = $returnedData->{'RequestData'};
    foreach my $serviceResults (@$parsedResponse){   
        print "Service Type: " . $serviceResults->{'ServiceType'} . "\n";
        if($serviceResults->{'ServiceType'} eq 'Recognition' and $serviceResults->{'RecognitionType'} eq "ExtractText"){
            print "Recognition Type: ". $serviceResults->{'RecognitionType'} . "\n";      
            print "Recognition Data: " . $serviceResults->{'data'};
        } 
        elsif($serviceResults->{'ServiceType'} eq 'Conversion'){
            $urls = $serviceResults->{'urls'}; 
            print "URL List: \n";
            foreach my $url (@$urls){
                print $url . "\n";
            } 
        } else{
            print("Unexpected service type. \n");
        }        
    }
}catch{
    print "Failed to parse JSON: " . 

Perl Queueing Tutorial

Below is an end-to-end example of submitting a request for various methods using Perl programming language:

; }