1

I am trying to query a PDF document field using Azure Document Intelligence with the Layout Model. Initially, I tested it in the Document Intelligence Studio by uploading the file and adding the query: Product_Net_Weight to retrieve the field Product Net Weight from the PDF. This worked perfectly, and I was able to see the exact value in the JSON results under the fields section.

However, when I attempted the same thing using Postman to call the API with the same query, I received a JSON response, but the API response does not contain the fields value.

My questions are:

Why is the API response missing the fields section? Am I sending the request incorrectly? We need the fields section in the response; otherwise, it is not possible to fetch the queried parameter value from the content section.

Screenshots: Screenshot of Studio Results JSON response (Contains Query field): Screenshot of Studio Results JSON response

Screenshot of API Call from Postman with Query: Screenshot of API Call from Postman with Query

Screenshot of API Results JSON response (Does not contain Query field): Screenshot of API Results JSON response

For Your Refference Here are the Curl commands of API Calls used for testing above case:

curl -X POST "https://doc-int-ai-poc.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-lay… \
 -H "Ocp-Apim-Subscription-Key: ***********" \
 -H "Content-Type: application/json" \
 -d '{
   "urlSource": "**************",
   "queryFields": ["Product_Net_Weight"]
 }'
curl -X GET "https://doc-int-ai-poc.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-lay… \
  -H "Ocp-Apim-Subscription-Key: *********************" \
  -H "Accept: application/json"

Additional Context: I have verified that the query string is correctly formatted, and it worked in the Document Intelligence Studio. Yet, when using the API, I am unable to fetch the same data. Can someone help me troubleshoot this issue?

Thank you!

1 Answer 1

0

The issue you're running into is a missing features=queryFields flag in your POST: prebuilt-layout API call.

The prebuilt-layout model is intended for extraction of pages, paragraphs, tables from your document, and doesn't include fields by default.

According to Microsoft's documentation found here, if you want to also allow extraction of fields from the document, you have to include the feature flag in your request as follows:

POST https://{endpoint}/documentintelligence/documentModels/prebuilt-layout:analyze?api-version=2024-11-30&features=queryFields&queryFields=Product_Net_Weight HTTP/1.1
Host: *.cognitiveservices.azure.com
Content-Type: application/json
Ocp-Apim-Subscription-Key:

{
  "urlSource": "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/rest-api/layout.png"
}

Document Intelligence Studio will automatically add that flag to your requests when you add query fields via the UI.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.