I am trying to create a contacting using a POST from and external source. I have added the below to my HTTP-Functions page. I know the content is properly being retrieved and parsed because when I try to insert this into a collection rather than calling WixCrm it work properly. But with WixCrm I encounter this error: Unhandled rejection Error: Bad Request: please check the user inputs.
And nothing is added to contacts. Any ideas how to fix this? I have even tested using nothing but the sample code for wix-crm-backend and get the same error.
export async function post_testingcrm1(request) {
console.log('Creating a Customer')
let options = {
"headers": {
"Content-Type": "application/json"
},
"suppressAuth": true
};
return await request.body.json()
.then((body) => {
console.log(body)
let contactInfo = {
"firstName": body.first_name,
"lastName": body.last_name,
"emails": [body.email],
"phones": [body.phone_number]
}
wixCrm.createContact(contactInfo)
.then(contactId => {
console.log(contactId)
})
return serverError(options);
})}