Hello:
I have successfully added a Wix endpoint receiver per this article, for my site:
https://support.wix.com/en/article/corvid-exposing-a-site-api-with-http-functions
This is being called by a third party API (Stripe, in this case), to process additional actions on the Wix side as transactions occur.
One of the actions I want to do is send emails on some events (received by the hook endpoint) to select administrators.
I have email sending working in general from the backend code, for our Contact Us form.
But, inside the endpoint web hook, when I go to send the email through the Wix wixCRM.emailContact function it fails, with this error:
{“message”:“Invalid identity”,“details”:{“errorcode”:“-5002”}}
The exact same email code, executed from the front end Wix web site, calling to the backend, works fine, email gets sent (to the fixed contact, using an email trigger template).
This is the code in the endpoint hook that fails with the error above.
import wixCRM from 'wix-crm-backend';
...
let contactid = "b5287b55-7cae-408e-8d80-bfc2ff66592a";
console.log( "message: " + message );
try {
return await wixCRM.emailContact( 'RiPGtn2', contactid, { // targeted email campaign for contact us submission
"variables":
{
//"message": message
"message": "test!"
}
});
} catch( err ) {
console.log( "email failed: " + err );
return Promise.reject( err );
}
I suspect the Wix endpoint (a POST function, in this case) simply does not have the right permissions or ‘identity’ as the error message notes, to send email through the Wix backend email functionality.
I would prefer not to use a third party email provider, like sendgrid, if possible.
Is this just a limitation of of the Wix endpoint backend, or a bug?
Thanks in advance for the help,
Dan Pronovost