Getting API error when trying to delete an order

hi getting this:

'API error: Client error: `DELETE https:\/\/api.infusionsoft.com\/crm\/rest\/v1\/orders\/` resulted in a `405 Method Not Allowed`

i’ve tried REST:

$infusionsoft->orders()->delete($orderID);

and XML:

$infusionsoft->data()->delete('Job', $orderId);

both have denied to delete the order, while i tested using HTTP DELETE request:

https://api.infusionsoft.com/crm/rest/v1/orders/{orderId}

it worked!

The REST API does expose DELETE /crm/rest/v1/orders/{id}, but the PHP SDK doesn’t implement it as a direct delete($id) method. Instead, the SDK handles deletes by first retrieving the resource and then calling delete() on the object.

Here’s the correct approach in the SDK:

$order = $infusionsoft->orders()->find($orderId);
$order->delete();

So while your raw HTTP DELETE request works against the REST API, when using the PHP SDK you’ll want to follow the pattern above.

what about:

$infusionsoft->data()->delete('Job', $id);

thanks

@pagedesigner,

In XML-RPC you can delete the Invoice using the “InvoiceService.deleteInvoice” Endpoint.

https://developer.keap.com/docs/xml-rpc/#invoice-delete-an-invoice

Not sure if that is available in the newer SDK, but was available in the original SDK as “$app->deleteInvoice($id);”.

What is the issue on your side, it is because there is a Payment attached to it?

I see in the REST v1 Delete Order will work but if it does not have a Payment. But the XML-RPC will fully delete the Invoice with the Payment.

1 Like

$app->deleteInvoice($id); this will delete the invoice, i want to delete the order via PHP SDK, its not a big deal im using REST endpoint alternately to do this, but i was curious why this is not working now, previously it was working, and my order is blank with no payment and item in it