I am working on a Zap through the CLI that will send data to an external api from any existing form on Zapier. I have this so far:
const createDoc = async (z, bundle) => {
const data ={
tenant: bundle.inputData.tenant,
first_name: 'Dave',
middle_initial: '',
last_name: 'Cedrone',
email: 'email@email.com',
phone_numbers: :{
number: '(555) 555-3490',
type: 'mobile'
}],
origin: 'Website',
business_type: 'Personal',
business_name: '',
country_code: 'US',
lob: 'Auto',
payment_type: '',
lead_format: "json",
data: {
Version: 8.0
}
}
const urldes = `<myapi.com>?X-API-Key=${bundle.inputData.API_Key}`
const options = {
method: 'POST',
url: urldes,
body: JSON.stringify(data),
"Content-Type": "application/json"
};
const response = await z.request(options);
if (response.status !== 200) {
throw new z.errors.Error(
`Unexpected status code ${response.status}`,
response.status
);
}
return response.json;
};
module.exports = {
key: 'doc',
noun: 'Document',
display: {
label: 'Link Form Fields to Leads',
description: 'This will link the fields of your form to the Leads.'
},
operation: {
inputFields: :
{key: 'API_Key', label:'API Key', required: true},
{key: 'tenant', label:'Tenant ID', required: true},
],
perform: createDoc,
}
};
It seems to connect except it doesn’t send any data from the JSON I have here. I’ve tried it without the quotes, with double quotes, and everything else I can think of. I get a 400 error that nothing was sent over.