Hello Ubana, Siddharth,
Issue:
Customer trying to use the query fields feature using the Azure .NET C# SDK and asked if Azure Document Intelligence C# SDK support add-on query field.
Error Message:
ErrorCode: InvalidArgument Content: {"error":{"code":"InvalidArgument","message":"Invalid argument.","innererror":{"code":"ParameterMissing","message":"The parameter urlSource or base64Source is required."}}}
Solution:
Among all the suggested answers, customer use AnalyzeDocumentOptions
to directly add the query fields and call AnalyzeDocumentAsync
with the AnalyzeDocumentOptions
.
The steps are as follow:
- Create
BinaryData
from the document content. - Initialize
AnalyzeDocumentOptions
with the model ID,BinaryData
, and other parameters. - Add
QueryFields
directly toAnalyzeDocumentOptions
. - Call
AnalyzeDocumentAsync
with theAnalyzeDocumentOptions
.
The code example:
BinaryData data = BinaryData.FromBytes(Content);
var analyzeOptions = new AnalyzeDocumentOptions(modelId, data)
{
Pages = "1-2",
Features = { DocumentAnalysisFeature.QueryFields },
QueryFields = { "FullName", "CompanyName", "JobTitle" }
};
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, analyzeOptions);
AnalyzeResult result = operation.Value;
If this is helpful, don't forget to close up the thread here by upvoting and accept it as an answer.