Azure AI Document intelligence, getting InvalidContentSourceFormat error

574 views Asked by At

Currently i am working with azure ai document intelligence form recognizer. I have written the logic and hit my api. My api will take azure form recognizer endpoint, and apikey to connect. But i am getting below error. Please help to solve on this.

com.azure.core.exception.HttpResponseException: Status code 400, "{"error":{"code":"InvalidArgument","message":"Invalid argument.","innererror":{"code":"InvalidContentSourceFormat","message":"Invalid content source: Url must be http or https."}}}"
    at com.azure.ai.formrecognizer.documentanalysis.implementation.util.Transforms.getHttpResponseException(Transforms.java:276) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]
    at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.analyzeDocument(DocumentAnalysisClient.java:332) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]
    at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.lambda$analyzeActivationOperation$2(DocumentAnalysisClient.java:302) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]
    at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.lambda$beginAnalyzeDocumentFromUrlSync$0(DocumentAnalysisClient.java:181) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]
    at com.azure.core.util.polling.SimpleSyncPoller.<init>(SimpleSyncPoller.java:65) ~[azure-core-1.40.0.jar:1.40.0]
    at com.azure.core.util.polling.SyncPoller.createPoller(SyncPoller.java:127) ~[azure-core-1.40.0.jar:1.40.0]
    at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.beginAnalyzeDocumentFromUrlSync(DocumentAnalysisClient.java:174) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]
    at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.beginAnalyzeDocumentFromUrl(DocumentAnalysisClient.java:157) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]
    at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.beginAnalyzeDocumentFromUrl(DocumentAnalysisClient.java:113) ~[azure-ai-formrecognizer-4.0.8.jar:4.0.8]

I have tried by checking all possible to ways to findout, couldn't able to find. Even i tried to check azure documentation and support faq.

1

There are 1 answers

1
Rishabh Meshram On

Based on the provided error log, it indicates that the URL you are passing to the beginAnalyzeDocumentFromUrl method is not in the correct format.

As you are using beginAnalyzeDocumentFromUrl, the URL input must be in the format of http or https.

To fix the issue please check your source input format and you can check below sample input for reference and testing:

https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-layout.pdf

I was able execute beginAnalyzeDocumentFromUrl method with above sample URL. enter image description here

For more details regarding implementation, you can check this documentation.