Can't Update Invoices Via API

I’m trying to update an invoice’s discount amount using a PUT cURL but keep getting an html page with the message “Whoops, looks like something went wrong.”

This is the code I’m running:
$url = ‘https://account.website.com/api/v1/invoices/11878’;
$data = json_encode(array(
‘discount’ => 50
));
$response = putObjectNinja($url, $data);

I know putObjectNinja works fine because I can update the client’s name using the same function:

$url = ‘https://account.trunorthwarranty.com/api/v1/clients/12’;
$data = json_encode(array(
‘name’ => “New ClientName”,
));
$response = putObjectNinja($url, $data);

Any ideas what would be preventing me from updating the invoice’s discount amount?

When updating an invoice you need to pass in all of the current values. You’ll typically want to use a GET to load the invoice, make the change and then save it.

We plan to change this in v2 to support only changing specified fields.