Skip to main content
Best answer

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


scottsmeester303
Forum|alt.badge.img

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!!! 

Best answer by ikbelkirasanBest answer by ikbelkirasan

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

 

View original
Did this topic help you find an answer to your question?
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

Troy Tessalone
Forum|alt.badge.img+14

Hi @scottsmeester303 

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


scottsmeester303
Forum|alt.badge.img

Hey @Troy Tessalone - still need help!


Troy Tessalone
Forum|alt.badge.img+14

@ikbelkirasan Can you chime in here?


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • Answer
  • May 28, 2021

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

 


scottsmeester303
Forum|alt.badge.img

That worked!! Thank you, gents!


scottsmeester303
Forum|alt.badge.img

Bonus points: what did I do wrong? 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • May 28, 2021

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


scottsmeester303
Forum|alt.badge.img

It does. Thank you for the explanation.

A+ to the Zapier Community…

edit: “dev forum” to Community