Posting a PDF file using cURL

Hi!

I am trying to post a pdf file using cURL, but I'm struggling to do so.

The API documentation of the receiving party says:

Finally, send an HTTP POST request to the uploadUrl without a Content-Type header. You can use this cURL command to try the upload URL. Supported formats are .pdf , .png , and .jpg .

curl --location --request POST '$YOUR_URL' \
--form 'Key="INPUT/$YOUR_ID"' \
*[several other --form]*
--form 'file=@"$YOUR_FILE_PATH"'

When you upload a document with the HTTP POST cURL command, Amazon sends a 204: No content error, but the document was successfully uploaded .

So I created a REST query in my app that is like follows:

I do get the 204: No content as a response, however the file is never uploaded to the third party.

I tried several things:

  • format of the file line with and without '@', with and without quotes,
  • switching to a raw body in the Retool query
  • switching to a x-www-form-urlencoded body in the Retool query

It did not seem to change anything (same response, file not uploaded).

Has anyone ever succeeded in uploading a file using cURL on Retool?
Am I doing anything wrong with the format of the query, especially the 'file' line?

Thank you so much for your help!

Hey @Florian_Baron, just to clarify, the 'file' key value is the url of the file object? Can you share the full API docs link so I can take a look?

Hi @joeBumbaca!

Many thanks for your response.
This is the API documentation of the solution I'm trying to implement

The section is under

Step 3: Send POST request

Finally, send an HTTP POST request to the uploadUrl without a Content-Type header. You can use this cURL command to try the upload URL. Supported formats are .pdf , .png , and .jpg .

In the meantime, I'm discussing with them to troubleshoot the queries - I'm not excluding the issue is coming from them and not Retool.
As soon as I get an answer, I'll update the thread.

I'm updating the ticket as I finally found the solution: it was not coming from Retool but instead from the documentation of the third party: the endpoint was expecting a base64 encoded document and not the URL of an online stored document...

I just replaced the file field with {{ fileDropzoneStatus.value['0'].base64Data }} and it worked!

1 Like