(Unrecognized property: id) when trying to update via save() in infusionsoft REST for products

I have been able to do the following methods: GET, POST, and DELETE.
My problem is the PATCH. I am unable to update the products…

What I have done:
-added public $updateVerb = ‘patch’; in ProductService instead of default put to follow docs
Code to update:
$product = $app->infusionsoft->products()->find($payload[“id”]);
//the code above works, it returns the product
$product->product_desc = “Updated!”;
$result = $product->save();

response I get is:
“error: Client error: PATCH https://api.infusionsoft.com/crm/rest/v1/products/39?access_token=****************** resulted in a 400 Bad Request response:\n{“message”:“Unrecognized property: id”}\n”

Can anybody point me to the right direction?

With patch you don’t send the field field. You only send what you want to update. It is complaining that you are trying to update a read only field.

2 Likes

Update:
$product= $infusionsoft->products();
$product->id = $payload[“id”];
unset($payload[“id”]);
$result = $product->mock($payload)->save();

And modified RestModel’s save() to:
$id = $this->{$this->primaryKey};
unset($this->{$this->primaryKey});
$data = $this->client->restfulRequest(strtolower($this->updateVerb),
$this->getFullUrl($id), (array)$this->toArray());

Thanks @bradb!