Best answer

Why do I keep getting "Got a result missing the "id" property"?

  • 27 May 2021
  • 8 replies
  • 225 views

Userlevel 1
Badge

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":[{"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!!! 

icon

Best answer by ikbelkirasan 28 May 2021, 18:45

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

8 replies

Userlevel 7
Badge +14

Hi @scottsmeester303 

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

Userlevel 1
Badge

Hey @Troy Tessalone - still need help!

Userlevel 7
Badge +14

@ikbelkirasan Can you chime in here?

Userlevel 7
Badge +12

@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;
});

 

Userlevel 1
Badge

That worked!! Thank you, gents!

Userlevel 1
Badge

Bonus points: what did I do wrong? 

Userlevel 7
Badge +12

@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?

Userlevel 1
Badge

It does. Thank you for the explanation.

A+ to the Zapier Community…

edit: “dev forum” to Community