Not sure what I’m doing wrong, but I’m unable to correctly Poll an API endpoint when setting up a trigger on the Zapier Platform.
In Code Mode, I’ve put the following:
const options = {
url: 'https://api.vouchfor.com/v1/vouches',
method: 'GET',
headers: {
'X-Api-Key': bundle.authData.X-API-TOKEN
},
params: {
},
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
// You can do any parsing you need for results here before returning them
return eresults];
});
Whilst in Form Mode I’ve put:
- GET: https://api.vouchfor.com/v1/vouches
- HTTP HEADER: X-Api-Key : {{bundle.authData.X-API-TOKEN}}
The response I’m getting is:
Code Mode
API is not defined
What happened (You are seeing this because you are an admin):
Executing triggers.new_vouch.operation.perform with bundle
API is not defined
Form Mode
Invalid API Response:
- Results must be an array, got: object, ({"vouches": {"id":"vWqCoyHzAA","status":"RESPONDED)
- Got a result missing the "id" property (d{"id":"vWqCoyHzAA","status":"RESPONDED","url":"https://app.vouchfor.com/vWqCoyHzAA"},{"id":"2Yk92vHCUg","status":"OPENED","url":"https://app.vouchfor.com/request/2Yk92vHCUg"},{"id":"auxP1iDLfF","status":"RESPONDED","url":"https://app.vouchfor.com/au)
What happened (You are seeing this because you are an admin):
Executing triggers.new_vouch.operation.perform with bundle
Invalid API Response:
- Results must be an array, got: object, ({"vouches": {"id":"vWqCoyHzAA","status":"RESPONDED)
- Got a result missing the "id" property (d{"id":"vWqCoyHzAA","status":"RESPONDED","url":"https://app.vouchfor.com/vWqCoyHzAA"},{"id":"2Yk92vHCUg","status":"OPENED","url":"https://app.vouchfor.com/request/2Yk92vHCUg"},{"id":"auxP1iDLfF","status":"RESPONDED","url":"https://app.vouchfor.com/au)
What Zapier returns tin the HTTP response content / what I get in say Postman:
{
"vouches": >
{
"id": "vWqCoyHzAA",
"status": "RESPONDED",
"url": "https://app.vouchfor.com/vWqCoyHzAA"
},
{
"id": "2Yk92vHCUg",
"status": "OPENED",
"url": "https://app.vouchfor.com/request/2Yk92vHCUg"
}...
I’ve tried a few different tweaks with the code, however I am having no luck. Any help anyone can provide would be greatly appreciated!