Hello,
I am trying to allow an external webhook to post new contacts to my site by calling a post function in HTTP-Functions. This post runs multiple steps so I am confident that I am receiving the data correctly, I am even getting it into a custom collection correctly but can not seem to get it into Wix Contacts. Below is the relevant code and subsequent error.
return request.body.json()
.then((body) => {
console.log(body)
var customerid = body.id
var firstName = body.first_name;
var lastName = body.last_name;
var email = body.email;
var birthday = body.birth_date;
var address = body.address;
var loyaltynumber = body.loyalty_number;
var loyaltyrefid = body.loyalty_ref_id;
var okToEmail = body.ok_to_email;
var zipcode = body.zipcode;
var totalpurchases = body.total_purchases;
var totalvisits = body.total_visits;
var vehicles = body.vehicles;
var phone = body.phone_number
wixCrm.updateContact( {
"firstName": firstName,
"lastName": lastName,
"emails": [email],
"phones": [phone],
"CustomerID": customerid,
"Vehicle": vehicles,
"Birthday": birthday
} )
.then( (contactId) => {
console.log(contactId) // contact created
} );
Which give me this error:
"["Unhandled rejection Error: Bad Request: please check the user inputs.\n at /dynamic-modules/edm_root/93c8bfb0-904d-11ea-b5a7-6b45394bc288/node_modules/@wix/wix-crm-backend/src/server-api.ts:32:11\n at Generator.throw (<anonymous>)\n at rejected (/dynamic-modules/edm_root/93c8bfb0-904d-11ea-b5a7-6b45394bc288/node_modules/@wix/wix-crm-backend/dist/src/server-api.js:6:65)\n at bound (domain.js:420:14)\n at runBound (domain.js:433:12)\n at tryCatcher (/elementory/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/elementory/node_modules/bluebird/js/release/promise.js:547:31)\n at Promise._settlePromise (/elementory/node_modules/bluebird/js/release/promise.js:604:18)\n at Promise._settlePromise0 (/elementory/node_modules/bluebird/js/release/promise.js:649:10)\n at Promise._settlePromises (/elementory/node_modules/bluebird/js/release/promise.js:725:18)\n at _drainQueueStep (/elementory/node_modules/bluebird/js/release/async.js:93:12)\n at _drainQueue (/elementory/node_modules/bluebird/js/release/async.js:86:9)\n at Async._drainQueues (/elementory/node_modules/bluebird/js/release/async.js:102:5)\n at Immediate.Async.drainQueues [as _onImmediate] (/elementory/node_modules/bluebird/js/release/async.js:15:14)\n at processImmediate (internal/timers.js:439:21)\n at process.topLevelDomainCallback (domain.js:131:23)"]"
I have also tried doing this on an afterInsert hook since I am also depositing this info into a different collection but I get the same “Bad Request: please check the user inputs”. I confirmed that my custom fields are names properly.
Any ideas?