0

I am trying to pass a parameter with base encoded data to a curl request. It complains about the argument list too long because the base encoded string is too long. Based on the responses from other posts, I tried to store the content in a file and tried passing the file as a parameter. There, I am getting an error: The file is corrupted or format is unsupported

Here is what both my requests looks like

curl -v -i POST "https://contoso.azure.com/formrecognizer/documentModels/prebuilt-idDocument:analyze?api-version=2022-06-30-preview" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <key>" --data "{'base64Source': '<base64encoded_data>'}"

curl -v -i POST "https://contoso.azure.com/formrecognizer/documentModels/prebuilt-idDocument:analyze?api-version=2022-06-30-preview" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <key>" --data "{'base64Source': '@file.txt'}"

I put the base64 encoded data in the file as is - file_screenshot

Any help is appreciated.

ask4sunny
  • 3
  • 2
  • Does this answer your question? [curl: argument list too long](https://stackoverflow.com/questions/54090784/curl-argument-list-too-long) – Ecstasy Jun 22 '22 at 03:55
  • [cUrl : Argument list too long](https://unix.stackexchange.com/questions/174350/curl-argument-list-too-long) and [Why do I receive a UnsupportedMediaType message when trying to analyze a form?](https://stackoverflow.com/questions/56381040/why-do-i-receive-a-unsupportedmediatype-message-when-trying-to-analyze-a-form) – Ecstasy Jun 22 '22 at 03:55

1 Answers1

1

CURL has ability to perform POST operation from a file. Checkout the following line block.

curl -X POST -d @filename.txt "https://contoso.azure.com/formrecognizer/documentModels/prebuilt-idDocument:analyze?api-version=2022-06-30-preview" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <key>" --data "{'base64Source': '<base64encoded_data>'}"

curl -X POST -d @filename.txt "https://contoso.azure.com/formrecognizer/documentModels/prebuilt-idDocument:analyze?api-version=2022-06-30-preview" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <key>" --data "{'base64Source': '@file.txt'}"

Does this answer the your question.

Sairam Tadepalli
  • 1,563
  • 1
  • 3
  • 11