Skip to main content

I have configured Dynamic Fields to fetch user defined fields with a custom API calls.

const options = {
  url: 'https://api.legodesk.com/case/rest/contact/fetch/custom/fields',
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': bundle.authData.Authorization,
  },
  params: {

  }
}

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

    return results;
  });

//This Api will return as per below format data. 

o
   {
      "id": "61d2936e9c3eec05bcdd0d73",
      "label": "2nd Phone Number",
      "key": "lego_ylog_2nd_Phone_Number",
      "type": "text",
      "helpText": null,
      "placeholder": null,
      "required": false,
      "dynamic": null,
      "choices": ]
   }
]

Now i want configure Dynamic Fields into the action but my actual body request for the API is

{
   "firstName": "Mohan Kumar",
   "lastName": "Mohan Kumar",
   "email": "mohan4534@gmail.com",
   "phone": "9567687987",
   "gender": "Male",
   "address": "Bangalore",
   "district": "Bangalore",
   "state": "Karnataka",
   "dob": "2000-01-06T07:46:09.161Z",
   "pin": 560068,
   "customField": {
      "lego_ylog_2nd_Phone_Number": "8976786756"
   }
}

How to configure Dynamic Fields into the action API request as per above? 

const options = {
  url: 'https://api.legodesk.com/case/rest/contact/create/new/or/update',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'bundle.authData.Authorization'
  },
  params: {

  },
  body: {
    'firstName': 'bundle.inputData.firstName',
    'lastName': 'bundle.inputData.lastName',
    'email': 'bundle.inputData.email',
    'phone': 'bundle.inputData.phone',
    'gender': 'bundle.inputData.gender',
    'address': 'bundle.inputData.address',
    'district': 'bundle.inputData.district',
    'state': 'bundle.inputData.state',
    'pin': 'bundle.inputData.pin',
    'dob': 'bundle.inputData.dob'
  }
}

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

Tucked away in https://platform.zapier.com/docs/knownissues ...

  • If you are adding dynamic fields you’ll want to use Code Mode when configuring the API request and use something like ...bundle.inputData to reference all of the fields that were created dynamically at runtime.