简体   繁体   English

没有从“预建发票”中获取订单项

[英]Not Getting Line Items from "prebuilt-invoice"

If I submit an invoice in the Form Recognizer Studio, it finds and presents the line items from the invoice.如果我在 Form Recognizer Studio 中提交发票,它会查找并显示发票中的行项目。

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.如果我然后使用同一张发票并使用 Form Recognizer Studio 中的代码提交它,我不会获得 JSON 中的行项目。我确实获得了所有其他数据。

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. @VasaviLankipalle 你是对的。 What I was looking for was that the AnalyzeResult JSON would just include the line items without the extra step of iterating through them.我一直在寻找的是AnalyzeResult JSON 将只包含行项目,而无需迭代它们的额外步骤。

I did end up iterating through the line items and building my own JSON to send back from the controller.我确实最终遍历了订单项并构建了我自己的 JSON 以从 controller 发回。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么不允许从字符串中通过 'ref' 获取字符? - Why getting char by 'ref' from string is not allowed? 从 Azure function .net6 获取 Bindingdata(函数 v4) - Getting Bindingdata from Azure function .net6 (function v4) 从 Xunit 调用时如何从 Razor 页面返回 Partial 而没有得到 System.NullReferenceException - How to return Partial from Razor Page when called from Xunit without getting System.NullReferenceException 从 Blazor 组件 EventCallback 获取 ChangeEventArgs 值? 重构后目前为null - Getting the ChangeEventArgs value from Blazor component EventCallback? Currently is null after refactor 从 asp.net 核心中的 appsettings.json 读取配置时出现空错误 - Getting null error when reading configuration from appsettings.json in asp.net core 尝试从 header 获取角色声明时,获取 NullReferenceException 和 object 引用未设置为 object 的实例 - Getting NullReferenceException and object reference not set to an instance of an object when trying to get the role claim from the header 无法格式化 ToolStripComboBox 控件中的项目 - Unable to format items in a ToolStripComboBox control 报错Argument 2: cannot convert from 'System.Threading.Tasks.ParallelLoopState' to 'System.Threading.CancellationToken' 如何解决? - Getting error Argument 2: cannot convert from 'System.Threading.Tasks.ParallelLoopState' to 'System.Threading.CancellationToken' how to solve? 日志未写入 ApplicationInsights - Logs not getting written to ApplicationInsights 如何编写删除 REST API 接受一长串要删除的项目? - How to write delete REST API that accepts a long list of items to delete?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM