Hi, guys!
I have converted my app to Zapier CLI platform and trying to add new action using JS.
But I have an issue with submitting the inputData to the server.
The thing is that I’m using nested JSON structure that backed supports:
{
"custom_object": {
"resource_id": 123,
"resource_type": "Contact"
}
}
Hence, my keys in inputFields looks like “custom_object__resource_id”, “custom_object__resource_type”.
In the legacy actions, perform method looks like below and it turns __ into nested object:
const perform = (z, bundle) => {
return z.legacyScripting.run(bundle, 'create', 'update_section');
};
But how should I write the new “perform” function to convert my keys “custom_object__resource_id” into the structure I need? Is there a helper method I can apply or something?
When I simply do this:
const perform = (z, bundle) => {
const promise = z.request({
url: 'https://myapp.com/api/v1/sections',
method: 'POST',
body: bundle.inputData,
headers: {
'content-type': 'application/json'
}
});
return promise.then(response => JSON.parse(response.content));
};
it just sends the inputData as is (“custom_object__resource_id”) which is not acceptable by the backend.
Any help would be appreciated :)