Skip to main content

I’ve tried all the similar solutions to people who had the same problem and I keep getting “Got a result missing the "id" property”. Following is the structure of my returned data (the first ‘id’ =12 is the id):

{
"data":
{
"type": "stage",
"id": 12,
"attributes": {
"color": "#9bedcf",
"createdAt": "2021-03-05T17:54:49.000Z",
"name": "Becoming KLT",
"order": 2,
"updatedAt": "2021-03-11T17:19:02.000Z"
},
"relationships": {
"creator": {
"data": {
"type": "user",
"id": 1
}
},
"prospects": {
"links": {
"related": "https://api..."
}
},
"updater": {
"data": {
"type": "user",
"id": 1
}
}
},
"links": {
"self": "https://api..."
}
}
]
}

Following is my current code

const options = {
url: 'https://apiURL/api/v2/stages',
method: 'GET',
headers: {
'Accept': 'application',
'Authorization': `Bearer ${bundle.authData.access_token}`
},
params: {

}
}

return z.request(options).then((response) => {
response.throwForStatus();
const result = z.JSON.parse(response.content);
result.id = result.id;
return result];
});

And I’m getting the following error:

Invalid API Response:
- Got a result missing the "id" property ({"data":t{"type":"stage","id":1,"attributes":{"color":"#e8eefe","createdAt":"2021-01-29T23:43:13.000Z","name":"Cold / Not Started","order":1,"updatedAt":"2021-02-16T23:53:40.000Z"},"relationships":{"creator":{"data":null},"prospects":{"links":{"relat)
What happened (You are seeing this because you are an admin):
Executing triggers.get_stages.operation.perform with bundle

Please help!!! 

Hi @scottsmeester303 

Were you able to figure this out or do you still need help?


Hey @Troy Tessalone - still need help!


@ikbelkirasan Can you chime in here?


@Troy Tessalone Sure thing!

Hi @scottsmeester303 - The following code snippet should do the trick:

const options = {
url: "https://apiURL/api/v2/stages",
method: "GET",
headers: {
Accept: "application",
Authorization: `Bearer ${bundle.authData.access_token}`,
},
params: {},
};

return z.request(options).then((response) => {
response.throwForStatus();
const items = response.json.data;
return items;
});

 


That worked!! Thank you, gents!


Bonus points: what did I do wrong? 


@scottsmeester303 - Awesome!

Ok so, you were returning an object that contains a property called data which contained the items array. The trigger expects the items array to be returned so what the code does here is that it extracts the array from the data property. Each item does already have an id so there’s no need to manipulate that. Make sense?


It does. Thank you for the explanation.

A+ to the Zapier Community…

edit: “dev forum” to Community