Form Recognizer API (v2.1)

Form Recognizer extracts information from forms and images into structured data. It includes the following options:

  • Form - Extracts information from forms (PDFs and images) into structured data based on a model created from a set of representative training forms. Form Recognizer learns the structure of your forms to intelligently extract text and data. It ingests text from forms, applies machine learning technology to identify keys, tables, and fields, and then outputs structured data that includes the relationships within the original file.
  • Receipt - Detects and extracts data from receipts using optical character recognition (OCR) and our receipt model, enabling you to easily extract structured data from receipts such as merchant name, merchant phone number, transaction date, transaction total, and more.
  • Business Card - Detects and extracts data from business cards using optical character recognition (OCR) and our business card model, enabling you to easily extract structured data from business cards such as contact names, company names, phone numbers, emails, and more.
  • Layout - Extracts text and table structure from documents using optical character recognition (OCR).
  • Invoices - Detects and extracts data from invoices using optical character recognition (OCR) and our invoice understanding deep learning models, enabling you to easily extract structured data from invoices such as customer, vendor, invoice ID, invoice due date, total, invoice amount due, tax amount, ship to, bill to, line items and more.
  • ID Documents - Detects and extracts data from identification documents using optical character recognition (OCR) and our ID document model, enabling you to easily extract structured data from ID documents such as first name, last name, date of birth, document number, and more.

Analyze Invoice - Get Analyze Invoice Result

Query the status and retrieve the result of an Analyze Invoice operation. The URL to this interface can be obtained from the 'Operation-Location' header in the Analyze Invoice response. We recommend calling this operation no more than once a second.

Select the testing console in the region where you created your resource:

Australia East Brazil South Canada Central Central India Central US Central US EUAP East Asia East US East US 2 France Central Germany West Central Italy North Japan East Japan West Korea Central North Central US North Europe South Africa North South Central US Southeast Asia Switzerland North Switzerland West UAE North UK South West Central US West Europe West US West US 2 West US 3 Norway East Jio India West

Request URL

Request parameters

string

Format - uuid. Analyze operation result identifier.

Request headers

string
Subscription key which provides access to this API. Found in your Cognitive Services accounts.

Request body

Response 200

JSON fields in the response body:

Field Type Description
status String Analyze Receipt operation status. Possible values:
  • notStarted: The analysis operation has not started.
  • running: The analysis operation is in progress.
  • failed: The analysis operation has failed.
  • succeeded: The analysis operation has succeeded.
If the status is succeeded, the response JSON will include the receipt understanding and text recognition results. The receipt understanding result is organized as a dictionary of named field values, where each value contains the extracted text, normalized value, and corresponding word elements. The text recognition result is organized as a hierarchy of lines and words, with text, bounding box and confidence information.
createdDateTime String Date and time (UTC) when the operation was created.
lastUpdatedDateTime String Date and time (UTC) when the status is last updated.
analyzeResult Object Results of the analyze operation.
readResults [Object] List of of extracted text result for each page in the input document.
lines [Object] List of text lines. The lines are sorted top to bottom, left to right, although in certain cases proximity is treated with higher priority. As the sorting order depends on the detected text, it may change across images and OCR version updates. Thus, business logic should be built upon the actual line location instead of order. This field only appears when includeTextDetails is set to true.
words [Object] List of words in the text line.
boundingBox [Number] Quadrangle bounding box of a line or word, depending on the parent object, specified as a list of 8 numbers. The coordinates are specified relative to the top-left of the original image. The eight numbers represent the four points, clockwise from the top-left corner relative to the text orientation. For image, the (x, y) coordinates are measured in pixels. For PDF, the (x, y) coordinates are measured in inches.
text String Extracted field text in documentResults, or the text content of a word/line in readResults.
confidence Number Confidence value.
width Number The width of the image/PDF in pixels/inches, respectively.
height Number The height of the image/PDF in pixels/inches, respectively.
angle Number The general orientation of the text in clockwise direction, measured in degrees between (-180, 180].
page Integer The 1-based page number in the input document.
unit String The unit used by the width, height and boundingBox properties. For images, the unit is "pixel". For PDF, the unit is "inch".
language String The detected language on the page overall or of a specific line if different from the page.
version String The version of schema used for this result.
documentResults [Object] An array of objects, each representing a receipt detected in the input document.
docType String The value is set to "prebuilt:receipt" to indicate a receipt document.
pageRange [Integer, Integer] First and last page numbers where the receipt is found. Currently, only single-page receipts are supported.
fields Object Dictionary of detected field values.
type String Data type of the field value. Currently, possible types include "string", "number", "phoneNumber", "date", "time", "array", and "object".
valueString String Semantic value of "string" fields.
valueNumber Number Semantic value of "number" fields.
valuePhoneNumber String Semantic value of "phoneNumber" fields.
valueDate String Semantic value of "date" fields.
valueTime String Semantic value of "time" fields.
valueArray [Object] Semantic value of "array" fields.
valueObject Object Semantic value of "object" fields.
elements [String] When includeTextDetails is set to true, a list of references to the text elements constituting this field.

Supported fields:
Name Type Description Example
CustomerName string Customer being invoiced. If a standalone customer name is not identified, the CustomerAddressRecipient, BillingAddressRecipient, ShippingAddressRecipient or ServiceAddressRecipient will be returned. "Fabrikam Residences"
CustomerId string Reference Id for the customer. "1A4B9C16D25E"
PurchaseOrder string A purchase order reference number. "1123581321"
InvoiceId string Id for this specific invoice (often “Invoice Number”). "182764125"
InvoiceDate date Date the invoice was issued. "01/02/2019"
DueDate date Date payment for this invoice is due. "08/02/2019"
 VendorName  string Vendor who has created this invoice. If a standalone vendor name is not identified, the VendorAddressRecipient or RemittanceAddressRecipient will be returned.  Contoso, Ltd.
VendorAdress string Mailing address for the Vendor, which is not identified as a RemittanceAddress. "Plum Tree Tower #9180 2247 West Beech Lane Oak City, IL 41349"
VendorAddressRecipient string Name associated with the VendorAddress. "Contoso, Ltd."
CustomerAddress string Mailing address for the Customer, which is not identified as another address type. "PO Box #29401 Palm Tree City, AK 02139"
CustomerAddressRecipient string Name associated with the CustomerAddress. "Fabrikam Residences"
BillingAddress string Explicit billing address for the customer. "Spruce Towers #7654 357 North Cherry St Hawthorne, VT 84231"
BillingAddressRecipient string Name associated with the BillingAddress. "Fabrikam, Inc"
ShippingAddress string Explicit shipping address for the customer. "987 West Chestnut Ave Larch City, AR 03491"
ShippingAddressRecipient string Name associated with the ShippingAddress. "Fabrikam Residences"
SubTotal number Subtotal field identified on this invoice. 1850.00
TotalTax number Total tax field identified on this invoice 150.00
InvoiceTotal number Total new charges associated with this invoice. 2000.00
PreviousUnpaidBalance  number Explicit previously unpaid balance. 3000.00
AmountDue number Total Amount Due to the vendor. 48000.00
ServiceStartDate date First date for the service period (for example, a utility bill service period)  “11/15/2018”
ServiceEndDate date End date for the service period (for example, a utility bill service period)  “12/14/2018” 
ServiceAddress string Explicit service address or property address for the customer. "56 S Willow Street Ash, ND 98123"
ServiceAddressRecipient string Name associated with the ServiceAddress. "Fabrikam Residences"
RemittanceAddress string Explicit remittance or payment address for the customer. "PO Box #87910 Elm, TX 02193"
RemittanceAddressRecipient string Name associated with the RemittanceAddress. "Contoso Pharmaceuticals"

{
    "status": "succeeded",
    "createdDateTime": "2020-06-09T03:18:46Z",
    "lastUpdatedDateTime": "2020-06-09T03:18:55Z",
    "analyzeResult": {
        "version": "2.1.0",
        "readResults": [
            {
                "page": 1,
                "angle": 0,
                "width": 8.5,
                "height": 11,
                "unit": "inch"
            }
        ],
        "pageResults": [
            {
                "page": 1,
                "tables": [
                    {
                        "rows": 6,
                        "columns": 5,
                        "cells": [
                            {
                                "text": "1",
                                "boundingBox": [
                                    0.75,
                                    4.9,
                                    1.6283,
                                    4.9,
                                    1.6283,
                                    5.1667,
                                    0.75,
                                    5.1667
                                ]
                            },
                            {
                                "columnIndex": 1,
                                "text": "Project fee",
                                "boundingBox": [
                                    1.6283,
                                    4.9,
                                    5.4867,
                                    4.9,
                                    5.4867,
                                    5.1667,
                                    1.6283,
                                    5.1667
                                ]
                            },
                            {
                                "columnIndex": 3,
                                "text": "125",
                                "boundingBox": [
                                    6.281,
                                    4.9,
                                    6.6217,
                                    4.9,
                                    6.6217,
                                    5.1667,
                                    6.281,
                                    5.1667
                                ]
                            },
                            {
                                "columnIndex": 4,
                                "text": "125",
                                "boundingBox": [
                                    6.6217,
                                    4.9,
                                    7.75,
                                    4.9,
                                    7.75,
                                    5.1667,
                                    6.6217,
                                    5.1667
                                ]
                            },
                            {
                                "rowIndex": 1,
                                "text": "25",
                                "boundingBox": [
                                    0.75,
                                    5.1667,
                                    1.6283,
                                    5.1667,
                                    1.6283,
                                    5.4333,
                                    0.75,
                                    5.4333
                                ]
                            },
                            {
                                "rowIndex": 1,
                                "columnIndex": 1,
                                "text": "Junior researcher hours",
                                "boundingBox": [
                                    1.6283,
                                    5.1667,
                                    5.4867,
                                    5.1667,
                                    5.4867,
                                    5.4333,
                                    1.6283,
                                    5.4333
                                ]
                            },
                            {
                                "rowIndex": 1,
                                "columnIndex": 3,
                                "text": "25",
                                "boundingBox": [
                                    6.281,
                                    5.1667,
                                    6.6217,
                                    5.1667,
                                    6.6217,
                                    5.4333,
                                    6.281,
                                    5.4333
                                ]
                            },
                            {
                                "rowIndex": 1,
                                "columnIndex": 4,
                                "text": "625",
                                "boundingBox": [
                                    6.6217,
                                    5.1667,
                                    7.75,
                                    5.1667,
                                    7.75,
                                    5.4333,
                                    6.6217,
                                    5.4333
                                ]
                            },
                            {
                                "rowIndex": 2,
                                "text": "10",
                                "boundingBox": [
                                    0.75,
                                    5.4333,
                                    1.6283,
                                    5.4333,
                                    1.6283,
                                    5.7,
                                    0.75,
                                    5.7
                                ]
                            },
                            {
                                "rowIndex": 2,
                                "columnIndex": 1,
                                "text": "Binding and printing",
                                "boundingBox": [
                                    1.6283,
                                    5.4333,
                                    5.4867,
                                    5.4333,
                                    5.4867,
                                    5.7,
                                    1.6283,
                                    5.7
                                ]
                            },
                            {
                                "rowIndex": 2,
                                "columnIndex": 3,
                                "text": "5",
                                "boundingBox": [
                                    6.281,
                                    5.4333,
                                    6.6217,
                                    5.4333,
                                    6.6217,
                                    5.7,
                                    6.281,
                                    5.7
                                ]
                            },
                            {
                                "rowIndex": 2,
                                "columnIndex": 4,
                                "text": "50",
                                "boundingBox": [
                                    6.6217,
                                    5.4333,
                                    7.75,
                                    5.4333,
                                    7.75,
                                    5.7,
                                    6.6217,
                                    5.7
                                ]
                            },
                            {
                                "rowIndex": 3,
                                "columnIndex": 2,
                                "rowSpan": 3,
                                "text": "Subtotal Sales Tax Total",
                                "boundingBox": [
                                    5.4867,
                                    5.7,
                                    6.281,
                                    5.7,
                                    6.281,
                                    6.5,
                                    5.4867,
                                    6.5
                                ]
                            },
                            {
                                "rowIndex": 3,
                                "columnIndex": 4,
                                "text": "800",
                                "boundingBox": [
                                    6.6217,
                                    5.7,
                                    7.75,
                                    5.7,
                                    7.75,
                                    5.9667,
                                    6.6217,
                                    5.9667
                                ]
                            },
                            {
                                "rowIndex": 4,
                                "columnIndex": 4,
                                "text": "37",
                                "boundingBox": [
                                    6.6217,
                                    5.9667,
                                    7.75,
                                    5.9667,
                                    7.75,
                                    6.2333,
                                    6.6217,
                                    6.2333
                                ]
                            },
                            {
                                "rowIndex": 5,
                                "columnIndex": 4,
                                "text": "837",
                                "boundingBox": [
                                    6.6217,
                                    6.2333,
                                    7.75,
                                    6.2333,
                                    7.75,
                                    6.5,
                                    6.6217,
                                    6.5
                                ]
                            }
                        ]
                    }
                ]
            }
        ],
        "documentResults": [
            {
                "docType": "prebuilt:invoice",
                "pageRange": [
                    1,
                    1
                ],
                "fields": {
                    "VendorName": {
                        "type": "string",
                        "valueString": "Trey Research",
                        "text": "Trey Research",
                        "boundingBox": [
                            0.8346,
                            1.2014,
                            2.8039,
                            1.2014,
                            2.8039,
                            1.5012,
                            0.8346,
                            1.5012
                        ],
                        "page": 1,
                        "confidence": 0.998
                    },
                    "VendorAddress": {
                        "type": "string",
                        "valueString": "5678 Cherrywood Lane Spruce Town, MD, 02145",
                        "text": "5678 Cherrywood Lane Spruce Town, MD, 02145",
                        "boundingBox": [
                            0.8316,
                            1.8268,
                            2.3484,
                            1.8268,
                            2.3484,
                            2.0974,
                            0.8316,
                            2.0974
                        ],
                        "page": 1,
                        "confidence": 1
                    },
                    "InvoiceDate": {
                        "type": "date",
                        "valueDate": "2020-06-08",
                        "text": "June 8, 2020",
                        "boundingBox": [
                            6.9321,
                            1.8268,
                            7.6653,
                            1.8268,
                            7.6653,
                            1.9304,
                            6.9321,
                            1.9304
                        ],
                        "page": 1,
                        "confidence": 0.998
                    },
                    "InvoiceNumber": {
                        "type": "string",
                        "valueString": "842902938",
                        "text": "842902938",
                        "boundingBox": [
                            7.0524,
                            1.9968,
                            7.6661,
                            1.9968,
                            7.6661,
                            2.0921,
                            7.0524,
                            2.0921
                        ],
                        "page": 1,
                        "confidence": 0.999
                    },
                    "CustomerName": {
                        "type": "string",
                        "valueString": "Fabrikam, Inc.",
                        "text": "Fabrikam, Inc.",
                        "boundingBox": [
                            6.5949,
                            2.4584,
                            7.6582,
                            2.4584,
                            7.6582,
                            2.6163,
                            6.5949,
                            2.6163
                        ],
                        "page": 1,
                        "confidence": 0.997
                    },
                    "CustomerAddress": {
                        "type": "string",
                        "valueString": "1234 Rosewood Ave Mapleton, NJ 84115",
                        "text": "1234 Rosewood Ave Mapleton, NJ 84115",
                        "boundingBox": [
                            6.4577,
                            2.6918,
                            7.6645,
                            2.6918,
                            7.6645,
                            2.9774,
                            6.4577,
                            2.9774
                        ],
                        "page": 1,
                        "confidence": 0.986
                    },
                    "CustomerId": {
                        "type": "string",
                        "valueString": "3820350332",
                        "text": "3820350332",
                        "boundingBox": [
                            6.982,
                            3.1968,
                            7.6637,
                            3.1968,
                            7.6637,
                            3.2921,
                            6.982,
                            3.2921
                        ],
                        "page": 1,
                        "confidence": 0.977
                    },
                    "PurchaseOrderNumber": {
                        "type": "string",
                        "valueString": "42013380",
                        "text": "42013380",
                        "boundingBox": [
                            4.3319,
                            4.2869,
                            4.9356,
                            4.2869,
                            4.9356,
                            4.3923,
                            4.3319,
                            4.3923
                        ],
                        "page": 1,
                        "confidence": 0.843
                    },
                    "DueDate": {
                        "type": "date",
                        "text": "7/28/2020",
                        "boundingBox": [
                            6.0871,
                            4.2869,
                            6.7297,
                            4.2869,
                            6.7297,
                            4.4034,
                            6.0871,
                            4.4034
                        ],
                        "page": 1,
                        "confidence": 0.998
                    },
                    "SubTotal": {
                        "type": "number",
                        "valueNumber": 800,
                        "text": "800",
                        "boundingBox": [
                            7.3959,
                            5.7651,
                            7.5971,
                            5.7651,
                            7.5971,
                            5.8605,
                            7.3959,
                            5.8605
                        ],
                        "page": 1,
                        "confidence": 0.998
                    },
                    "TotalTax": {
                        "type": "number",
                        "valueNumber": 37,
                        "text": "37",
                        "boundingBox": [
                            7.466,
                            6.0318,
                            7.5966,
                            6.0318,
                            7.5966,
                            6.1271,
                            7.466,
                            6.1271
                        ],
                        "page": 1,
                        "confidence": 0.999
                    },
                    "TotalInvoiceAmount": {
                        "type": "number",
                        "valueNumber": 837,
                        "text": "837",
                        "boundingBox": [
                            7.3959,
                            6.2985,
                            7.5977,
                            6.2985,
                            7.5977,
                            6.3938,
                            7.3959,
                            6.3938
                        ],
                        "page": 1,
                        "confidence": 0.999
                    }
                }
            }
        ]
    }
}

Response 404

Invalid or expired result identifier.

{
  "error": {
    "code": "BadArgument",
    "message": "Operation ID is invalid or expired."
  }
}
{
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}

Response 500

Internal server error.

{
  "error": {
    "code": "Unspecified",
    "message": "Internal server error."
  }
}
{
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}

Response 503

Transient fault while querying Microsoft Azure storage services.

{
  "error": {
    "code": "StorageException",
    "message": "Transient fault occurred while querying Microsoft Azure storage services. Please try again later."
  }
}
{
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}

Code samples

@ECHO OFF

curl -v -X GET "https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}?" + queryString;

            var response = await client.GetAsync(uri);
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}");


            URI uri = builder.build();
            HttpGet request = new HttpGet(uri);
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "GET",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    // Request headers
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_GET);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('canadacentral.api.cognitive.microsoft.com')
    conn.request("GET", "/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('canadacentral.api.cognitive.microsoft.com')
    conn.request("GET", "/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://canadacentral.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/invoice/analyzeResults/{resultId}')
uri.query = URI.encode_www_form({
})

request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body