Response Processing
Reference documentation on processing responses using the Mindee client libraries.
Requirements
You'll need to have already sent a file or URL as described in the Send a File or URL section.
Overview
Depending on how you've sent the file, there are two ways of obtaining the result.
If you've sent via polling (or polling and webhook) you'll get the response directly in your method call.
If you've sent only via webhook, you'll receive the response on your Web server.
Here we'll go over how you can best process the results.
Load From Webhook
If you're using the webhook pattern, you'll need to use the payload sent to your Web server.
Reading the callback data will vary greatly depending on your HTTP server. This is therefore beyond the scope of this example.
Regardless of how you access the JSON payload sent by the Mindee servers, loading this data is done by using a LocalResponse class.
Once it is loaded you can access the data in exactly the same way as a polling response.
To verify the HMAC signature, you'll need the Signing Secret from the webhook:

Remember to use the appropriate Product/Model class, examples use ExtractionResponse.
Assuming you're able to get the raw HTTP request via the variable request .
Assuming you're able to get the raw HTTP request via the variable request .
Assuming you're able to get the raw HTTP request via the variable request .
Assuming you're able to get the raw HTTP request via the variable $requestBody .
Assuming you have a Web server instance myHttpServer .
Assuming you're able to get the raw HTTP request via the variable request .
The Response Object
This is the base object of the response.
It doesn't do much on its own except allow you to access the Inference object.
Remember to use the appropriate Product/Model class, examples use ExtractionResponse.
The response object can be used to retrieve the raw response from the server, as a JSON string:
The Inference Object
This is the top-level object in the response.
It contains the following attributes:
idUUID of the inferencemodelModel used for the inferencefileMetadata concerning the file used for the inferenceresultResult of inference processing, the most important portion of the response.Fields: For handling the extracted fields, see the Extraction Result section.
Raw Text: For using the extracted text, see the Response Processing section.
File Metadata
You can access various metadata concerning the file sent for processing:
namename of the file as sent in the initial request.aliasalias as sent in the initial request.page_countnumber of pages in the file as determined during processing.mime_typeMIME / media type of the file as determined during processing.
Access using the response object from either a polling response or a webhook payload.
Last updated
Was this helpful?

