API create contact says email is invalid


I have an API to create contacts that works perfectly. I began receiving leads and parse them out to this script. Everything works except the email. I receive an error saying the email is invalid. If I use a dummy email, the script works. Any help is appreciated!


A little more info: i receive the leads via email and parse out the email. every part works perfectly except when i try to send the email to hubspot it fails. thanks for your help!


the error message: {“status”:“error”,“message”:“Property values were not valid”,“correlationId”:“0871d267-3aa4-46d2-8c40-071543a2adaa”,“validationResults”:[{“isValid”:false,“message”:“Email address bigtestyguy@yahoo.com is invalid”,“error”:“INVALID_EMAIL”,“name”:“email”}],“requestId”:“29e8afc9319a982ae98a61d940ea11ab”}


I figured it out. the email received was piped to my script. for some reason, hubspot would not recognize the email but would recognize a pieced together email. so, I separated the email parts into two, before the @ and after the @, then pieced the email together in the array: $part1.’@’.$part2 and it works perfectly.

I post this solution for other developers.