If I submit an invoice in the Form Recognizer Studio, it finds and presents the line items from the invoice.
If I then take that same invoice and submit it using the code from the Form Recognizer Studio, I do not get the line items in the JSON. I do get all the other data.
Any idea why?
<TargetFramework>net6.0</TargetFramework>
<PackageReference Include="Azure.AI.FormRecognizer" Version="4.0.0" />
public async Task<IActionResult> ProcessInvoice(IFormFile pdfInvoice) {
try {
string endpoint = "https://xxx.cognitiveservices.azure.com/";
string key = "xxx";
AzureKeyCredential credential = new AzureKeyCredential(key);
DocumentAnalysisClient client = new DocumentAnalysisClient(new Uri(endpoint), credential);
using var stream = pdfInvoice.OpenReadStream();
AnalyzeDocumentOperation operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-invoice", stream);
AnalyzeResult result = operation.Value;
return Ok(JsonConvert.SerializeObject(result));
} catch (Exception ex) {
return BadRequest(ex.Message);
}
}
@VasaviLankipalle you are correct. What I was looking for was that the AnalyzeResult
JSON would just include the line items without the extra step of iterating through them.
I did end up iterating through the line items and building my own JSON to send back from the controller.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.