Hi there,
I am new to APIs and have very limited experience with them (and coding in general), but I am attempting to make an API request using Zapier’s Developer Platform.
I got past authentication but now I am struggling to effectively make an API request.
The error I am receiving is:
Invalid API Response: - Results must be an array
As per Zapier Documentation, I realize that I need to make sure the results are returned as an array.
I am uncertain of what I might add to the Code Editor to make that happen:
const options = {
url: 'https://api.helpscout.net/v2/reports/company',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${bundle.authData.access_token}`,
'X-TYPES': bundle.inputData.types
},
params: {
'start': '2021-01-01T12:00:00Z',
'end': '2021-01-02T12:00:00Z',
'types': bundle.inputData.types
}
}
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 results;
});
If anyone has any tips for a total beginner, I’d super appreciate a pointer in the right direction here!