Skip to main content
Best answer

Invalid API - I get missing the "id" property when I already have an "id" property


Hello,

I have an “id” property already in my response, under children:

 "kind": "Listing",
  "data": {
    "after": null,
    "dist": 1,
    "modhash": "",
    "geo_filter": "",
    "children": [
      {
        "kind": "t3",
        "data": {
          "approved_at_utc": null,
          "saved": false,
          "mod_reason_title": null,
          "gilded": 0,
	      "removal_reason": null,
          "link_flair_background_color": "",
          "id": "pc39rj",
          "is_robot_indexable": true,
        }
      }
    ],
    "before": null
  }
}

This is my API Endpoint Code…

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

I don’t really understand why it won’t pick it up... I am guessing I would need additional code in the parsing section?

Any help would be appreciated!

 

WDes

Best answer by ikbelkirasanBest answer by ikbelkirasan

Hi @WDES2021 - The id needs to be at the top level, that’s why it didn’t work. Try this out and see if fixes your issue:

return z.request(options).then((response) => {
  response.throwForStatus();

  const results = response.json.data.children.map((child) => {
    return {
      ...child,
      id: child.data.id,
    };
  });

  return results;
});

 

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.

2 replies

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

Hi @WDES2021 - The id needs to be at the top level, that’s why it didn’t work. Try this out and see if fixes your issue:

return z.request(options).then((response) => {
  response.throwForStatus();

  const results = response.json.data.children.map((child) => {
    return {
      ...child,
      id: child.data.id,
    };
  });

  return results;
});

 


  • Author
  • Beginner
  • 5 replies
  • August 27, 2021

Confirmed that resolved it. Thank you for the immediate response!