Question

Can we add more than one form field in Webhooks by Zapier?

  • 15 October 2023
  • 3 replies
  • 35 views

Hi there,

 

I’m trying to create an automation where new files added to a Dropbox folder will trigger a zap. That specific file then gets indexed to a vector database in the Vectara platform via a POST request in the Webhooks by Zapier action.

 

Screenshot of the webhook action is below:

 

As per API Definition | Vectara Docs, the doc_metadata has to be attached as a form field (-F or --form with curl). I tried adding it as a data field (-d or --data with curl), but it predictably didn’t work. I cannot pinpoint how I would be able to add another form field. 

 

Would love to get any help/insights on this. Appreciate it!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 6
Badge +8

Try the following and see if it works for you :)

Instead of “POST” as the action’s event, select “Custom Request”. Choose POST as the method. Then, in the data field, include the following:

{
  "file": “{{dynamic file URL from Dropbox link}}",
  "doc_metadata": {
    "filename": “{{your file name}}”
  }
}

Hey Todd,

 

Thanks for helping out. I tried sending it through the data field via Custom Request like you suggested and got this error:

 

“Failed to create a request in Webhooks by Zapier. Request entity too large. (HTTP Status Code: 400)”

 

I suspect this is because the file needs to be included as part of the form-data, and not in a JSON format. I’m not sure if doing a custom request supports sending file objects which is what I need. So unless the POST action supports sending more than one file, I may be out of luck. 

 

Userlevel 6
Badge +8

You may be right about the form data vs. JSON. But since the error code relates to the entity size of your request...I’m curious what the size of the Dropbox file you’re trying to send is. Looks like Vectara supports max file size of 10mb. Can you run a test with a file that is under 1mb and see if that behaves as expected?

If so, you may want to find a way to compress files before sending them to the Vectara API or limit the size of file uploads to Dropbox.

Otherwise, you may want to use a Code by Zapier step instead of Webhooks by Zapier. I’ve provided JS below that should get you started.

output = {data: ''};
const appKey = "eyJraWQ..."; // your JWT token
let appData = "";

try {
const formData = new FormData();
formData.append('file', new File(['{{FILE URL}}'], '{{FILE NAME}}'));

const appResp = await fetch(
'https://api.vectara.io:443/v1/upload?c={{customerId}}&o=4&d=true',
{
method: 'POST',
headers: {
'Authorization': 'Bearer ' + appKey
},
body: formData
}
);

appData = await appResp.text();
appData = JSON.parse(appData);
output.data = appData;
} catch (e) {
console.log(e.message);
}

Also, I’d recommend specifying the file name extension, if you have it. In your initial screenshot, you just wrote “Test Document”, but it may be better to have “Test Document.pdf” (for example).