frontend code:
import { overwriteContactInfo } from ‘backend/tests’;
$w.onReady(function () {
const contactId = “b98962d7-7031-4160-9003-93j7c009436c”;
const updatedContactInfo = {
name: {
first: “john”,
last: “brown”,
},
phones: [{
phone: “909090909”
}],
extendedFields: {
“custom.nif”: 200000000,
}
};
overwriteContactInfo(contactId, updatedContactInfo)
.then((updatedContact) => {
console.log(updatedContact);
return updatedContact;
})
.catch((error) => {
console.error(error);
});
backend code of tests:
export async function overwriteContactInfo(contactId, updatedContactInfo) {
// Get the contact’s last revision number
const myContact = await contacts.getContact(contactId);
const contactIdentifiers = {
contactId: contactId,
revision: myContact.revision
};
const options = {
allowDuplicates: false,
suppressAuth: true
};
return await contacts.updateContact(contactIdentifiers, updatedContactInfo, options);
}
on preview mode i get this error when i use the contactId of the administrator:
Error: message: Contact not found.
details:
applicationError:
description: Contact not found.
code: CONTACT_NOT_FOUND
data: {}
on live, when i log as the site owner (or any other), i get this error:
Error: Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information. — wix-thunde…entory-support-wix-code-sdk.102150f4.chunk.min.js:0
and this last link when clicked gives me:
AccessDenied
Access Denied
SM1M1EHJ1916DE6Z
IjrRmInMvzeCMXLXRWgkF+iS3wECeOeW5iORthFU471VwUY+lhTy/UYcVkagIKyts7PBfHNxKVs=
The only time i don’t get errors is on preview mode when i use the contactId of the a regular member (non-administrator).
The contact ID “b98962d7-7031-4160-9003-93j7c009436c” is the site owner that i get from _id of Members/FullData from the members collection.
And this is an example from updateContact - Velo API Reference - Wix.com
I’m frustrated. Can someone help?
well, here, I changed some information.