I am building in the Zapier platform doing a get request out to our servers and it is returned the following JSON
- Results must be an array, got: object, ({"1131810":{"campaigns"::{"campaignId":35924,"camp)
- Got a result missing the "id" property ({"campaigns"::{"campaignId":35924,"campaignName":"HR Job: Test - Electrical Engineer - 2021-08-19 test 1"}],"fields":{"email":"email@gmail.com","mobile":1412,"name":"Nick Tester"}})
How do a change the return to make the first value (e.g. 1131810 be the “id”) and then get all the other responses.
const timestart =Math.floor(Date.now() / 1000) - bundle.inputData.validthrutimestamp;
const endtime = Math.floor(Date.now() / 1000) - bundle.inputData.endtime
const options = {
url: `${bundle.authData.server}/org/${bundle.authData.orgId}/contacts`,
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': `Token ${bundle.authData.token}`
},
params: {
'reportType': bundle.inputData.statustype,
'startTimestamp': timestart,
'endTimestamp': endtime,
'list': `l${bundle.inputData.fields}]`
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
if (response.status == 401 || response.status == 400 ) {
throw new z.errors.RefreshAuthError();
}
const results = response.json;
// You can do any parsing you need for results here before returning them
return results;
});