Skip to main content
Best answer

Create "id" property with a parse first


matthewcharlesb
Forum|alt.badge.img

I am trying to fix the “Got a result missing the "id" property” issue.

return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const results = response.json;
    const sales = results["data"].map((item) => {
      return {
          ...item,
          id: item["record_id"],
      };
    });
    console.log(sales);
    return sales;
  });

In the code above, the “record_id” in our API contains a prefix of either “a_” or “t_” or “d_”. This means a “record_id” could be “a_123456”. I try to address it with:

return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const results = response.json;
    const sales = results["data"].map((item) => {
      return {
          ...item,
          id: item["record_id"].replace("a_",10).replace("t_",11),
      };
    });
    console.log(sales);
    return sales;
  });

However, when I view the output I get an error of: 

Invalid API Response: - Got a two or more results with the id of "10"

I would think it should return “10123456” based on the example above. Any input on why it’s not working properly? I’ve tried this in JSFiddle and it works fine.

Best answer by Troy TessaloneBest answer by Troy Tessalone

Hi @matthewcharlesb 

If you are creating a Zap app integration on the Zapier Developer Platform, then you should post your topic in the Developer Zone: https://community.zapier.com/for-developers-61

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

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31004 replies
  • Answer
  • December 6, 2023

Hi @matthewcharlesb 

If you are creating a Zap app integration on the Zapier Developer Platform, then you should post your topic in the Developer Zone: https://community.zapier.com/for-developers-61


matthewcharlesb
Forum|alt.badge.img