Adding Contact, returns 400 Bad Request, "Unrecognized property: email_opted_in"

Add Contact code that has been working for 11 months started getting back ‘400 Bad Request’ with message “Unrecognized property: email_opted_in”. This began happening at about 8:12 PM PDT last night (April 2, 2018)

I’m using the library from GitHub - infusionsoft/infusionsoft-php: PHP client library for the Infusionsoft API. , although not the latest changes from about a week ago, as that requires PHP 7+.

I’m not setting the email_opted_in option, and I don’t see that the Infusionsoft library code does either ( a “grep -R email_opted_in .” shows nothing)

I should also note that the Contact actually is created, even though an Exception/400 Bad Request is returned.

I am curious what the answer to this is as the same thing happened to us last night. I can tell you that we had to remove the email_opt_in property and instead use “opt_in_reason” and supply a reason. ex: “opt_in_reason:Contact gave explicit permission”. After making this change, our new contacts and updates started processing fine.

I would like to know why the sudden change without notice.

We never make it to the opt-in reason portion. In our code, we call:

$infusionsoft_contact = $this->infusionsoft_obj->contacts()->create($contact);

which works properly, then we call

$contact_save_result = $infusionsoft_contact->save();

at which point the Exception is thrown.

Without looking at the library code, I’m guessing the ->save operation is the first time we actually talk to the Infusionsoft API, thus the Exception happens there, not in the ->create operation above.

Our order of operations is normally Create, Save, Update Opt-In Reason.

I was hopeful that adding the opt-in reason to the Contact on initial creation would get around this issue, but the “Unrecognized property: email_opted_in” Exception is still thrown.

Using this method (setting the opt-in reason on Contact creation), the Contact is in fact created, with the opt-in reason that I set.

So if I’m understanding, you’re saying that it’s “working” functionally but is still throwing the error message?

It is “working”, yes, in the sense that the Contact is created, but once the Infusionsoft API library returns an Exception upon the attempted Contact creation, our code bails out, and does not run the Action Set that is supposed to be run for the newly created Contact, so for us, it is definitely broken.

1 Like

Thanks for letting us know, Mike.
This generally sounds like what is happening to me, however, as far as I can tell, neither I nor the Infusionsoft PHP API Library is sending email_opted_in during Contact creation, yet I’m seeing an error as if it were sent (according to your explanation). I’m hopeful this will be fixed/caught during the code fix.

1 Like

I take this back, after my call to the Infusionsoft PHP API Library, $infusionsoft_contact = $this->infusionsoft_obj->contacts()->create($contact); , [email_opted_in] => 1 is set in the returned object.
Looking into how this happens.

I understand what is happening now. My code looks like this:

$infusionsoft_contact = $this->infusionsoft_obj->contacts()->create($contact);
$contact_save_result = $infusionsoft_contact->save();

The call to ->save() is redundant; $this->save() is called within ->create(). ->create() returns what the API responded with, and email_opted_in is set in that object. When I try to call ->save() on that object, I get the “Unrecognized property: email_opted_in” error.

Removing the redundant call to ->save fixes the issue.

1 Like