Reputation: 125
I'm trying to send some data to an API but Zapier will only send the first line that is in my body any suggestions on how to get all the data to send to the API. So in the code below the z.JSON.stringify(bundle.inputData.data)
will send but
'items': stringify(bundle.inputData.items)
will not send.
const options = {
url: 'https://us1.pdfgeneratorapi.com/api/v3/templates/41993/output',
method: 'POST',
headers: {
'X-Auth-Key': 'censored:64:5ebbff0676',
'Content-Type': 'application/json; charset=utf-8',
'X-Auth-Secret': 'censored:64:a5e9b35af8',
'Accept': 'application/json',
'X-Auth-Workspace': 'censored:27:384b1d0d0f'
},
params: {
'format': 'pdf',
'output': 'url'
},
body: z.JSON.stringify(bundle.inputData.data),
'items': z.JSON.stringify(bundle.inputData.items)
};
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content);
// You can do any parsing you need for results here before returning them
return results;
});
Upvotes: 0
Views: 481
Reputation: 5262
This is working as intended. You're sending the items
property in the options
object, which z.request
doesn't recognize and is ignoring. If you only want to send bundle.inputData.items
, then assign that to the body
property. If you want to combine them, then do something like body: {items: bundle.inputData.items, body: bundle.inputData.data}
Upvotes: 0