/// <summary> /// Recognizes values from one or more receipts. /// </summary> /// <param name="receipt">The stream containing the one or more receipts to recognize values from.</param> /// <param name="recognizeReceiptsOptions">A set of options available for configuring the recognize request.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="RecognizeReceiptsOperation"/> to wait on this long-running operation. Its <see cref="RecognizeReceiptsOperation.Value"/> upon successful /// completion will contain the extracted receipt.</returns> public virtual RecognizeReceiptsOperation StartRecognizeReceipts(Stream receipt, RecognizeReceiptsOptions recognizeReceiptsOptions = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(receipt, nameof(receipt)); recognizeReceiptsOptions ??= new RecognizeReceiptsOptions(); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormRecognizerClient)}.{nameof(StartRecognizeReceipts)}"); scope.Start(); try { FormContentType contentType = recognizeReceiptsOptions.ContentType ?? DetectContentType(receipt, nameof(receipt)); Response response = ServiceClient.AnalyzeReceiptAsync(contentType, receipt, includeTextDetails: recognizeReceiptsOptions.IncludeFieldElements, cancellationToken); string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader); return(new RecognizeReceiptsOperation(ServiceClient, Diagnostics, location)); } catch (Exception e) { scope.Failed(e); throw; } }