How to download a file through API after the initial binary response? Formstack

Hi,

These are the API details I am working through - /download/:submission_id/:field_id

I am trying to download a file through API, but the API call results in binary encoding of the file.

The link above says - “Download previously uploaded file via submission. This API will send a 302 redirect response and redirect to a signed URL to download the file. The file itself is not in the initial 302 redirect response itself.”

I want to download the previously uploaded file via submission. How do I go about downloading the file after the initial response?

Thank you.

Hi,

Can you try to use ResourcePath property? This will save response date to a file.

Regards,

if the above answer doesnt work, you can use invoke code activity (select c# as the language)

the below link is an example for downloading salesforce attachment (http request returns binary response which is converted to a file)

Thank you. I did use the ResourcePath property. As you can see in the image I had uploaded, the “Download Resource” field is populated. I have provided the path to Downloads folder in that property, but nothing gets downloaded. I have verified that the file exists within the API I am calling.

Hi,

To isolate cause, can you try to run the following sample in your environment?
This sample dowloads html file to project root folder as test.html.

Sample20220728-3.zip (2.3 KB)

If it works, can you try to modify settings, then run?

Regards,

1 Like

Thank you, this worked. I was able to download the test.html file. I modified the settings in the same activity to download the file from formstack. It worked. The file I wanted was downloaded.

Do you happen to know how to make the resource path dynamic? The name of incoming files would keep changing. I want the bot to download which ever file is present in the API call.

I was able to make resource path dynamic and download any file passed through API. Please disregard my last question. Thank you.

Thank you, I’ll keep this as back up. For now, the above answer worked.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.