How to download a file that requires authentication

I am using the transcription service Rev via its API.

Rev’s API requires authentication in plain header, not Basic Authentication - API Documentation - Authentication - Rev
I am already using the “HTTP” module with header “Authorization” of value"Rev [ClientAPIKey]:[UserAPIKey]".

Now I need to download a transcript file.

As per API Documentation - Get order information - Rev, the URL at which the downloadable transcript is located is in the form https://www.rev.com/api/v1/attachments/stRinG-OF-teXT-liKE-thIs/content

But that file is not publicly accessible. It, too, requires authentication. I think this makes the “Get File” module useless.

I have tried “HTTP” again - and this does allow access to the file. But the results pane just shows binary data (“Buffer, codepage: binary … End of data sample, buffer was originally 157524 bytes long. SHA1: xxxxxxxxxxx”)

So, I suppose the question is - how do I download that binary data as an actual file?

For instance, I want to add that file to an Airtable attachment field. On the Make side, this accepts only “File URL” and “File Name”.

Hi @RobertAndrews ,

There you have the content of your file. :slight_smile:
However, I checked the airtable API and it seems like it’s not possible to upload files. Instead, you should pass-through an URL that will be used by airtable to download the document and store a copy at their end.
You can consider creating a second scenario that uses parameters to request the right file from Rev and then pass the URL of the webhook with the correct parameters to Airtable to download the correct document. Another option would be to use a cloud storage service like Google Drive. You can upload the file to Google Drive and then pass the sharable link to Airtable’s attachment field.

I hope this helps you find the right solution.

Glenn - Callinetic

1 Like

Thanks for the ideas, but what I mostly don’t know is how to get the binary data out of the response and into a file in the first place.

To extract binary data from a response and save it as a file, you can use the toString function which is available as text function. For example, if you are trying to download a text file from Google Drive, you can use this function to convert the binary data to text and save it as a file.

image

image

image

Glenn - Callinetic

3 Likes

Not sure if it helps here, but I stumbled across this page when searching for ways to convert the response body of a custom webhook, which kept returning data in binary.

If you have control over the endpoint that you are querying and can customize the Return Headers, you can set the Content-type to be whatever you like

So in my example, I wanted to use the inbuilt “Parse Response” that is available in the “HTTP Make a Request” Module.

but my custom webhook kept returning the data in binary and thus couldn’t be parsed

I found if I wanted the data to be returned in JSON format so it could be parsed
I simply had to add the Content-type header to the Webhook response module and set it in my case to application/json;charset=utf-8

1 Like