I’ve been working with an that will POST data to a File Maker Pro endpoint when a new Cognito form is submitted. I’ve got pretty much everything working but from what I can tell the JSON being sent to the endpoint is not getting stringified correctly. I have 4 steps in the flow, 1. When Cognito form is submitted, 2. Send a POST request to get an bearer token for authentication, 3. Take the data from the Cognito for and stringify it using a Java script, 4. Send a post to the File Maker Endpoint for submission to the database to create a new entry.
The file maker pro server is a third party and its very strict on what needs to be sent to them. Data field must look like this…
{"fieldData":
{
"Payload":"{\"id_RepresentationType\":\"2\",\"injured\":{\"email\":\"Testemail\",\"firstName\":\"TestFirstName\",\"lastName\":\"TestLastName\",\"homePhone\":\"123-456-7890\"}}"
},
"script":"LeadIntakeV2.1"
}
The java code to stringify looks like this…
// Extracting data from the inputData object
var id_RepresentationType = inputData.id_RepresentationType;
var id_source = inputData.id_source;
var firstName = inputData.firstName;
var lastName = inputData.lastName;
var homePhone = inputData.homePhone;
var mobilePhone = inputData.mobilePhone;
var workPhone = inputData.workPhone;
// Creating an injured object with the extracted data
var injured = {
firstName: firstName,
lastName: lastName,
homePhone: homePhone,
mobilePhone: mobilePhone,
workPhone: workPhone,
};
// Creating a payload object with the extracted data and the injured object
var payload = {
id_RepresentationType: id_RepresentationType,
id_source: id_source,
injured: injured,
};
// Converting the payload object to a JSON string
var payloadString = JSON.stringify(payload);
// Creating an output object with a fieldData property that contains the payload
var output = { payloadString };
The output looks like this…
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/b8ca0474-9479-4efb-9c8e-c8f8ee6549dc.png)
However when I send this to the server I get an error code indicating to me that the data has not been properly stringified. Is there a way to ensure the data being posted will be stringified when its sent or does Zapier obfuscate that from the view of the Zapier user? Below is the error returned…
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/ad5e8689-1213-426c-8dd8-464229728d34.png)
Please let me know if anyone has encountered anything like this? I’m wondering if Zapier might not be the best solution for this but I feel like I’m extremely close to figuring this out and hoping someone here has ran into this.