Removing Company From Contact Through REST API

Afternoon,

I’ve been using the REST API pretty easily to add/edit contacts. I’m now working on being able to add/edit companies for these contacts.

I can add a company to InfusionSoft and apply it to a contact but my issue is removing the company from the contact.

No matter what I send the company stays attached to the contact. I’ve tried:

{‘company’:null}
(‘company’ {‘id’:0}}
(‘company’ {‘id’:‘’}}
(‘company’ {‘id’:‘’, ‘company_name’:‘’}}

And several other variations but that blasted company still sticks even when other fields get updated.

Would anybody be able to shed some light on something pretty simple I’m probably doing wrong here?

Thank you

What’s the complete JSON body of the request? You can’t just set the company field by itself I don’t think as I’m pretty sure that all calls have some requirements to what must be present. The portion for company would be “company”: {“id”: 0 } but it must be part of a correctly formatted record as a whole…share the exact json you’re sending and we can take a look at what might be tripping things up.

Hi John,

I’m using this, obviously with the access token and client id dropped in. I can update every other field fine.

$fields = json_encode(array(‘company’=>array(‘id’=>0)));
$url = 'https://api.infusionsoft.com/crm/rest/v1/contacts/CLIENTID?access_token=ACCESS;
$headers = array(‘Content-Type: application/json’);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, ‘PATCH’);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close($ch);

So $fields ends up being {“company”:{“id”:0}} in this case but I’ve tried many combinations as previously mentioned. Then when I echo out $result it still comes back with the full client info but more importantly this bit:

“company”:{“id”:165,“company_name”:“Test Ltd”}

Are you saying perhaps I need to send all the information again? Seems a bit excessive plus I’m sure you can just send “given_name” for example to update that one field. Can’t think of what else would be related to company I would need to include.

Thanks