Source:
<code>public static void main(final String[] args) { final FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() <START> .apiKey(new AzureKeyCredential("")) <END> .endpoint("https://{endpoint}.cognitiveservices.azure.com/") .buildAsyncClient(); String receiptUrl = "<LINK_0>"; PollerFlux<OperationResult, IterableStream<ExtractedReceipt>> analyzeReceiptPoller = client.beginExtractReceipt(receiptUrl, true, Duration.ofSeconds(1)); IterableStream<ExtractedReceipt> receiptPageResults = analyzeReceiptPoller .last() .flatMap(trainingOperationResponse -> { try { Thread.sleep(20000); } catch (InterruptedException e) { e.printStackTrace(); } if (trainingOperationResponse.getStatus().isComplete()) { System.out.println("Polling completed successfully"); return trainingOperationResponse.getFinalResult(); } else { System.out.println("polling completed unsuccessfully with status:" + trainingOperationResponse.getStatus()); return Mono.empty(); } }).block(); for (ExtractedReceipt extractedReceiptItem : receiptPageResults) { System.out.printf("Page Number %s%n", extractedReceiptItem.getPageMetadata().getPageNumber()); System.out.printf("Merchant Name %s%n", extractedReceiptItem.getMerchantName().getText()); System.out.printf("Merchant Address %s%n", extractedReceiptItem.getMerchantAddress().getText()); System.out.printf("Merchant Phone Number %s%n", extractedReceiptItem.getMerchantPhoneNumber().getText()); System.out.printf("Total: %s%n", extractedReceiptItem.getTotal().getText()); System.out.printf("Receipt Items: %n"); extractedReceiptItem.getReceiptItems().forEach(receiptItem -> { System.out.printf("Name: %s%n", receiptItem.getName().getText()); System.out.printf("Quantity: %s%n", receiptItem.getQuantity().getText()); System.out.printf("Total Price: %s%n", receiptItem.getTotalPrice().getText()); System.out.println(); }); } }</code><technical_language>put in a fake key, this throw exception</technical_language>

Target:
public static void main(final String[] args) { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .apiKey(new AzureKeyCredential("{api_key}")) .endpoint("https://{endpoint}.cognitiveservices.azure.com/") .buildAsyncClient(); String receiptUrl = "<LINK_0>"; PollerFlux<OperationResult, IterableStream<ExtractedReceipt>> analyzeReceiptPoller = client.beginExtractReceiptsFromUrl(receiptUrl); IterableStream<ExtractedReceipt> receiptPageResults = analyzeReceiptPoller .last() .flatMap(trainingOperationResponse -> { if (trainingOperationResponse.getStatus().isComplete()) { System.out.println("Polling completed successfully"); return trainingOperationResponse.getFinalResult(); } else { System.out.println("polling completed unsuccessfully with status:" + trainingOperationResponse.getStatus()); return Mono.empty(); } }).block(); receiptPageResults.forEach(extractedReceiptItem -> { System.out.printf("Page Number %s%n", extractedReceiptItem.getPageMetadata().getPageNumber()); System.out.printf("Merchant Name %s%n", extractedReceiptItem.getMerchantName().getText()); System.out.printf("Merchant Address %s%n", extractedReceiptItem.getMerchantAddress().getText()); System.out.printf("Merchant Phone Number %s%n", extractedReceiptItem.getMerchantPhoneNumber().getText()); System.out.printf("Total: %s%n", extractedReceiptItem.getTotal().getText()); System.out.printf("Receipt Items: %n"); extractedReceiptItem.getReceiptItems().forEach(receiptItem -> { System.out.printf("Name: %s%n", receiptItem.getName().getText()); System.out.printf("Quantity: %s%n", receiptItem.getQuantity().getText()); System.out.printf("Total Price: %s%n", receiptItem.getTotalPrice().getText()); System.out.println(); }); }); }