API retrieve response file | Community
Skip to main content
Answered

API retrieve response file


Forum|alt.badge.img

Hello,

I am publishing a survey where people should be able to upload some mandatory files (PDF mostly).
I am familiar with the Typeform API (Responses and Webhooks).
I want to retrieve all the answers, with the files, through the API and upload them on my server, thus i have two questions :
How long are the uploaded files in responses kept on Typeform ?

I see that through the webhook, i can retrieve the URL of the files : (e.g  "file_url": "https://api.typeform.com/responses/files/11f427717781XXXXXXX372c2daaf6e159e7128171e5a5/arthur_team.jpg"),  which seems okay.
However, when i read this API, https://developer.typeform.com/responses/reference/retrieve-response-file/ 

In this call, I can’t understand  all the parameters and no example are given. What is meant by “response_id” ?

https://api.typeform.com/forms/{form_id}/responses/{response_id}/fields/{field_id}/files/{filename}

And how are we supposed to know the filename (which is the name of the file given by the user), unless we already have the files (using webhooks) ?
Why not make alternative versions to retrieve  an uploaded file without a file name and/or all files for a given response ?

Thanks

Best answer by Liz

Hi @arthur Welcome to the community! Happy you’re here. 

To answer your first question, the files are available for as long as you keep the responses. If you delete the response, the file is deleted as well. So, if you want the file to be available forever, don’t delete the response associated with it! 

While I can’t speak to why our API works the way it does currently, I can give some insight on where to find this data. 

When you first grab the information from the Responses API, you can find the response ID and the file name in bold in the example below: 

 


  "total_items": 4,
  "page_count": 1,
  "items": [
    {
      "landing_id": "21085286190ffad1248d17c4135ee56f",
      "token": "21085286190ffad1248d17c4135ee56f",
      "response_id": "21085286190ffad1248d17c4135ee56f",
      "landed_at": "2017-09-14T22:33:59Z",
      "submitted_at": "2017-09-14T22:38:22Z",
      "metadata": {
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8",
        "platform": "other",
        "referer": "https://user_id.typeform.com/to/lR6F4j",
        "network_id": "responsdent_network_id",
        "browser": "default"

 

 

    "field": {
            "id": "X4BgU2f1K6tG",
            "type": "file_upload",
            "ref": "my_custom_file_upload_reference"
          },
          "type": "file_url",
          "file_url": "https://api.typeform.com/forms/lT9Z2j/responses/7f46165474d11ee5836777d85df2cdab/fields/X4BgU2f1K6tG/files/afd8258fd453-aerial_view_rural_city_latvia_valmiera_urban_district_48132860.jpg"
        },
    

You can then use these two items to call for the file. Let me know if you have any troubles making this call!

View original

13 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • Answer
  • June 15, 2021

Hi @arthur Welcome to the community! Happy you’re here. 

To answer your first question, the files are available for as long as you keep the responses. If you delete the response, the file is deleted as well. So, if you want the file to be available forever, don’t delete the response associated with it! 

While I can’t speak to why our API works the way it does currently, I can give some insight on where to find this data. 

When you first grab the information from the Responses API, you can find the response ID and the file name in bold in the example below: 

 


  "total_items": 4,
  "page_count": 1,
  "items": [
    {
      "landing_id": "21085286190ffad1248d17c4135ee56f",
      "token": "21085286190ffad1248d17c4135ee56f",
      "response_id": "21085286190ffad1248d17c4135ee56f",
      "landed_at": "2017-09-14T22:33:59Z",
      "submitted_at": "2017-09-14T22:38:22Z",
      "metadata": {
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8",
        "platform": "other",
        "referer": "https://user_id.typeform.com/to/lR6F4j",
        "network_id": "responsdent_network_id",
        "browser": "default"

 

 

    "field": {
            "id": "X4BgU2f1K6tG",
            "type": "file_upload",
            "ref": "my_custom_file_upload_reference"
          },
          "type": "file_url",
          "file_url": "https://api.typeform.com/forms/lT9Z2j/responses/7f46165474d11ee5836777d85df2cdab/fields/X4BgU2f1K6tG/files/afd8258fd453-aerial_view_rural_city_latvia_valmiera_urban_district_48132860.jpg"
        },
    

You can then use these two items to call for the file. Let me know if you have any troubles making this call!


Forum|alt.badge.img
  • Author
  • Explorer
  • 7 replies
  • June 15, 2021

Thanks for the answer and the help.
I can work with that ! :grinning:


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • June 15, 2021

Not a problem, @arthur ! Let me know if there’s anything else I can answer for you. :grin:


  • Navigating the Land
  • 1 reply
  • September 6, 2021

Hallo All,

I have similar problem about retrivieng file.

I already filled this template:

 https://api.typeform.com/forms/{form_id}/responses/{response_id}/fields/{field_id}/files/{filename}

with my relevant data, but when I open it in browser, I got this error.

“{"code":"AUTHENTICATION_FAILED","description":"Authentication credentials not found on the Request Headers"}”

Can someone help me?

Thanks in advance


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • September 7, 2021

Hi @BINUS When submitting the request, was the bearer auth token added to the headers? If not, you’ll want to be sure to include those!


greddie
  • Explorer
  • 2 replies
  • September 30, 2021

I have a related question…

i’m using Zapier to integrate into CapsuleCRM and I wanted to pass Capsule the file that had been uploaded in Typeform however I received the error

{"code":"AUTHENTICATION_FAILED","description":"Authentication credentials not found on the Request Headers"}

and I understand that I need to pass additional auth token to receive the file in this manner.  But why is it the URL that is stored in an exported XLS file from the Responses section has a different structure for the URL and that works without an auth token?

 

For example in my response XLS downloaded file the file URL is  

https://api.typeform.com/responses/files/b48849e3183513424757457742843b8146b48cb7102d9bd89bb892d63129114fb/1.docname.docx

and this works (the above will not work since I’ve changed the file name for privacy issues)

Buy the exact same transaction when passed to Zapier is recorded as...

https://api.typeform.com/forms/EM8HAxKq/responses/tt0vysfwtpaw0sarl6tt0vydkm01qz7x/fields/aHpnrPEx7TMV/files/c469ca0c1730-1.docname.docx

...and this fails for the reasons highlighted above?

Why can’t it pass the same public URL as in the exported XLS file or have an option to do that without having to send additional API calls?

Thanks for any advice in advance :) 

GREDDIE


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • September 30, 2021

Hi @greddie Happy little Friday! You can fix this issue by setting up your zap in the following way: 

 

Let me know if this doesn’t solve the issue!


greddie
  • Explorer
  • 2 replies
  • October 1, 2021

@Liz that's fantastic, it works a dream … easy when you know how ;) and saved me a whole bunch of time looking into API calls :punch: - thanks for the speedy response too !


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • October 1, 2021

Wahoo!! Glad that helps, @greddie ! Let me know if there’s anything else I can answer for you. :grinning:


  • Navigating the Land
  • 1 reply
  • February 13, 2022

Hi @Liz! Just wondering if there’s a way to fetch the file response in a get request, so we can preview the file before downloading. Thanks!


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • February 14, 2022

Hi @Alicexyz You can use the call here to specifically fetch a response file. 


  • Explorer
  • 2 replies
  • March 7, 2023

Hey @Liz Im accessing typeform from fivetran. What do I need to pass through there to access the raw file?


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • March 8, 2023

Hi @mj6ue I’m not familiar with Fivetran, but you can access the responses through the API call in the link above. 


Reply