Save contact not saving without email_addresses field RESTAPI

Hello, guys, I’m trying to save the contact but the problem is that if I do not provide the email or if i provide email_addresses like this

emial_addresses: [
     [
       'email': '', 
       'field': 'EMAIL1'
     ]
]

It does not saves the contact.But if I provide the email correctly all works well

I was going through your restapi it was said that the email_addresses option was optional.
image

Can you please tell what is going wrong.,

Here is the data structure

 [
                            'addresses' => [
                                [
                                    "line1" => '',
                                    "line2" => '',
                                    "locality" => 'Los Angeles',
                                    "postal_code" => '',
                                    "field" => "SHIPPING", //hard coded
                                ],
                                [

                                    "line1" => '',
                                    "line2" => '',
                                    "locality" => 'Los Angeles',
                                    "postal_code" => '',
                                    "field" => "BILLING", //hard coded
                                ]
                            ],
                            'birthday' => '1999-12-12',
//                            'email_addresses' => [
//                                [
//                                    'email' => "",
//                                    'field' => 'EMAIL1' //hard coded
//                                ]
//                            ],
                            'fax_numbers' => [
                                [
                                    'field' => "FAX1", //hard coded
                                    "number" => '',
                                    "type" => ''
                                ]
                            ],
                            'family_name' => '',
                            'given_name' => '',
                            'website' => '',
                            'source_type' => 'API'
                        ];

So to start with, if the code piece you posted is correct, then you mis-spelled email in email_addresses. Also, if that isn’t it, then have you tried not passing anything (in other words don’t pass an empty, therefor invalid, email) like this?

email_addresses: [
]

@John_Borelli Here is what I’m trying to save and no it is not being saved in infusionsoft and yes I have tried like this

email_addresses: [
]

Here is what I’m tying to save

$guest = [
                            'addresses' => [
                                [
                                    "line1" => '',
                                    "line2" => '',
                                    "locality" => 'Los Angeles',
                                    "postal_code" => '',
                                    "field" => "SHIPPING", //hard coded
                                ],
                                [

                                    "line1" => '',
                                    "line2" => '',
                                    "locality" => 'Los Angeles',
                                    "postal_code" => '',
                                    "field" => "BILLING", //hard coded
                                ]
                            ],
                            'birthday' => '1999-12-12',
                            'email_addresses' => [
                               
                            ],
//                            "email_status"=> null,
                            'fax_numbers' => [
                                [
                                    'field' => "FAX1", //hard coded
                                    "number" => '',
                                    "type" => ''
                                ]
                            ],
                            'family_name' => 'neon',
                            'given_name' => 'neon',
                            'website' => '',
                            'source_type' => 'API',
                            'custom_fields'=> [
                                [
                                    "id" =>72,
                                    "content" => $guests_ar["id"]
                                ]
                            ],
//                            "email_status" => 'asdasd',
                            "preferred_name" => 'asdasd'
//                            "email_status" => ''.$guests_ar["id"]
                        ];

Looking at the rest but the first thing I notice is that you’re not using the curly braces where you should. I would look again at documentation and the differences of when to use curly and non curly braces. One denotes an array while the other specifies objects and they must match what the endpoint is expecting to see.

@John_Borelli if that was the problem. Then it should be not be saving when I give a valid email. Why does it saves when I replace this 'email' => "", with this 'email' => "cs@cs.com",

I don’t know the answer to that. I do know that it does not match documentation and until it follows documentation, nothing else can be determined as correct or incorrect.

Hi @Rohan_Jalil,

Please note the Create a Contact description in its documentation indicates:

NB: Contact must contain at least one item in email_addresses or phone_numbers and country_code is required if region is specified.

image

For that reason, our documentation shows that email_addresses and phone_numbers are optional. Apologies for the confusion. If you have any suggestions on how we could make this clearer, let us know.