Issue with Data Extraction Using Prebuilt.Invoice Model and API Version 2023-10-31

Ivan Hernanz 0 Reputation points
2024-06-13T11:00:10.08+00:00

Hi,

I am encountering an issue while using the begin_analyze_document method with the Prebuilt.Invoice model and API version 2023-10-31. The error occurs when I call poller.result(), and the details are as follows:

poller.result()

Traceback (most recent call last):

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/base_polling.py", line 757, in run

self._poll()

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/base_polling.py", line 789, in _poll

raise OperationFailed("Operation failed or canceled")

azure.core.polling.base_polling.OperationFailed: Operation failed or canceled

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/_poller.py", line 251, in result

self.wait(timeout)

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer

return func(*args, **kwargs)

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/_poller.py", line 270, in wait

raise self._exception  # type: ignore

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/app/infraestructure/adapters/adapterextractor.py", line 158, in extraerMetadatos3

invoice: AnalyzeResult = poller.result()

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/_poller.py", line 251, in result

self.wait(timeout)

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer

return func(*args, **kwargs)

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/_poller.py", line 270, in wait

raise self._exception  # type: ignore

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/_poller.py", line 185, in _start

self._polling_method.run()

File "/home/ivanh/Proyectos/gpm_extraccion_20240418/env3.8/lib/python3.8/site-packages/azure/core/polling/base_polling.py", line 772, in run

raise HttpResponseError(response=self._pipeline_response.http_response, error=err) from err

azure.core.exceptions.HttpResponseError: (InternalServerError) An unexpected error occurred.

Code: InternalServerError

Message: An unexpected error occurred.

Exception Details: (InternalServerError) An unexpected error occurred.

Code: InternalServerError

Message: An unexpected error occurred.

The operation fails and throws an InternalServerError with the message "An unexpected error occurred." This exception appears to be raised during the polling phase after initiating the document analysis.

Notably, when I process the same document through Document Intelligence Studio, it returns the data correctly without any issues. This suggests that the document itself is not the problem.

I would appreciate your assistance in resolving this issue. Please let me know if you require any additional information or logs.

Thank you for your support.

Best regards,

Ivan Hernanz

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,505 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 15,836 Reputation points
    2024-06-13T20:52:29.93+00:00

    Hello @Ivan Hernanz , Thanks for using Microsoft Q&A Platform.

    Ensure you check the packages installed when working with API version 2023-10-31. It's important to have Python 3.8 or a later version included.

    Install the Azure Document Intelligence client library for Python with pip:

    pip install azure-ai-documentintelligence --pre
    

    Here is the sample you can refer to and the complete Github code .

    with open(path_to_sample_documents, "rb") as f:
    
        poller = document_intelligence_client.begin_analyze_document(
    
            "prebuilt-invoice", analyze_request=f, locale="en-US", content_type="application/octet-stream"
    
        )
    
    invoices: AnalyzeResult = poller.result()
    
    

    Is this something you are looking for?

    Regards,

    Vasavi

    -Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.

    0 comments No comments