Hi there ,
I am trying to write a record into a datacollection using zapier Webhook POST functionality. Basically, if I update a google spreadsheet, this information is to be recreated/posted into the datacollection.
Here is my code on the back-end:
import wixData from 'wix-data';
import {ok, response} from 'wix-http-functions';
export function post_NeedsAnalysis(request) {
return request.body.json()
.then(body => {
let recordInsert = {
"title": body.Respondent_ID,
"emailAddress": body.Email_Address,
"coachingTypenotes": body.Coaching_Type_Notes,
"generalCoachingNotes": body.General_Coaching_Notes,
"MentorshipNotes": body.Mentorship_Notes
};
return wixData.insert('Analysis',recordInsert)
.then(result=> ok({body: JSON.stringfly(result)}))
.catch(err => response({status: 500,body:err}));
}
);
}
The problem is that the webhook does post the data into the datacollection, but returns a ‘500’ error or “internal server error”, then attempts to re-post and ends up creating duplicates.
Any thoughts on why I am getting this error?
Thanks,
Shamal