Error creating contact using wix-crm

I’m trying to send a triggered email to new contacts after clicking a button but I’m receiving Bad Request: Please check the user inputs.

here is my code:

wixCrm . createContact ({ 
    "firstName" :  $w ( '#input1' ). value , 
    "emails" : [ $w ( "#input2" ). value ] 
}). then (( contactId ) => { 
    console . log ( contactId ); 
    wixCrm . triggeredEmails . emailContact ( 'donation_receipt' ,  contactId , { 
        variables : { 
            WelfareProject :  $w ( '#input4' ). value , 
            DonorName :  $w ( '#input1' ). value , 
            DonationAmount :  $w ( 'input3' ). value 
        } 
    }). then (( email ) => { 
        console . log ( "Email sent: "  +  email ); 
    }). **catch** (( emailErr ) => { 
        **let**  mailErr  =  emailErr ; 
        console . log ( mailErr ); 
    }); 
}); 

Can anyone help me :confused:

Are you checking that the value input by the user in input2 is an email?

I’ve set the input2 textbox type to email and add pattern validation to verify the email entered is of the right format, do i need to validate the email format with code as well?

I’ve validate the user input for email, but I receive undefined value for contactId

I have the same issue.
have been trying to fix for almoust 3 weeks.

When i enter new cotact details with new names and emailID. It returns the identityType: as “MEBER” then it appends the entered details to the existing contact entry.

BUT at the end returns “Error: Bad Requst: please check the user inputs”