I'm building an integration between Hubspot and our VoIP phone system. I want to create a new contact when a phone call is received (if I can't find the phone number associated with an existing contact). Is this possible? Here is my test code:
private void test()
{
var client = new RestClient("https://api.hubapi.com/");
client.Authenticator = new JwtAuthenticator(acessToken);
var request = new RestRequest("contacts/v1/contact/", Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(new
{
properties = new[] {
new { property ="email", value = "mytest@hotmail.com" },
new { property ="firstname", value = firstname },
new { property ="lastname", value = string.Empty },
new { property ="phone", value = phone }
}
});
IRestResponse response = client.Execute(request);
}
This works if I have a value in the email address variable, but will not if the email is blank. Obviously I won't have an email address initially when the call comes in.
You should be able to create a contact without an email. Are you omitting the email property entirely, or are you trying to set it to a blank string? You'll want to do the former to avoid HubSpot's email address validation checks.