Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Sep 25, 2024 03:17 PM
I'm trying to script a POST request to the Covve API to parse business cards. Their technical support says "the API does not support passing the file via URL. It only accepts uploading the file itself directly."
Is there a way to do this through Airtable, using the expiring URL? This is the relevant part:
const myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "multipart/form-data");
const formdata = new FormData();
formdata.append("file", photoURL);
const requestOptions = {
method: "POST",
headers: myHeaders,
body: formdata,
redirect: "follow"
};
let postResponse = await remoteFetchAsync(apiUrl, requestOptions);
Solved! Go to Solution.
Sep 26, 2024 03:27 PM
I figured it out. Added this step:
let response = await fetch(photoURL);
let fileBlob = await response.blob();
const formdata = new FormData();
formdata.append("file", fileBlob);
Our company doesn't allow integration like Make and won't approve consultants. This is my progress in learning Javascript.
Sep 25, 2024 08:16 PM
Have you tried using fetch() to get the file/blob from the URL and then passing the result as your file?
Sep 25, 2024 08:21 PM
I'm not too familiar with scripting. How would you do that?
Sep 26, 2024 12:59 AM - edited Sep 26, 2024 01:02 AM
Alternatively, if you would like to do this in a low-code way that doesn’t require scripting, you can always do this by using Make’s HTTP modules.
You can use the “Get A File” module to download the Airtable file, and then use the “Make a Request” module to send your POST API request.
Below is a screenshot of how this could look in Make.
If you’ve never used Make before, I’ve assembled a bunch of Make training resources in this thread.
For example, here is how you would instantly trigger a Make automation from Airtable by using a custom webhook.
I also give live demonstrations of how to use Make in many of my Airtable podcast appearances here.
For example, in this video, I show how to work with Airtable attachment arrays in Make.
.Hope this helps!
— ScottWorld, Expert Airtable Consultant
Sep 26, 2024 09:28 AM
@auekk2787 wrote:I'm not too familiar with scripting. How would you do that?
You are already using a version of fetch() in your existing script (remoteFetchAsync). Because attachment urls don't have any CORS restrictions, you can use regular fetch() with the url instead of remoteFetchAsync. You can read more about the difference between the two here.
What is your scripting background? Depending on how familiar you are with writing your own scripts, you might want to look for a non-scripting option, hire someone to write the script for you, or learn more about JavaScript.
Sep 26, 2024 03:27 PM
I figured it out. Added this step:
let response = await fetch(photoURL);
let fileBlob = await response.blob();
const formdata = new FormData();
formdata.append("file", fileBlob);
Our company doesn't allow integration like Make and won't approve consultants. This is my progress in learning Javascript.