Skip to main content
Question

Missing id property - have read numerous threads and still stuck

  • August 8, 2022
  • 1 reply
  • 47 views

Hi there,

 

I have read through numerous threads and I know that this problem is occurring because we return Id not id as an element in our api and that I need to change it to id through the code

{"Id":1,"Portfolio":null,"Code":"Dep","Active":true,"ParentCompany":0,"CompanyName":"Deputy Zapier QA","TradingName":"","BusinessNumber":"","CompanyNumber":"123 123 123","IsWorkplace":true,"IsPayrollEntity":true,"PayrollExportCode":"","Address":157,"}

 

I have tried to do this but no matter how many different ways of bashing my head against the metaphorical wall i cannot get it to work. Sample code below

const getList = (z, bundle) => {
  const promise = z.request({
    url: `https://${bundle.authData.endpoint}/api/v1/resource/Company/QUERY`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: '',
  });
  return promise.then((response) => {
    const results = response.json;
    return results.map((item) =>{
      results.id = results.Id;
      return item;
    });
  });
}

Please tell me what i need to modify to get this working because I have tried almost everything in many different ways and have read numerous threads. Thanks in advance.

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.

1 reply

Forum|alt.badge.img+9
  • Zapier Staff
  • 238 replies
  • August 18, 2022

Hi @SimonDeputy!
 

I see our Support team got back to you on this one, I’ll post that suggested solution here based on the code sample 👌 

 

In the results map, you should just need to reference item, instead of results. So

return results.map((item) =>{ results.id = results.Id; return item; });

should be

return results.map((item) =>{ item.id = item.Id; return item; });

Hope that suggestion helped you out!