Deleting in the ServiceAPI

Strangely enough there are multiple paths via which you might choose to delete a Record in the ServiceAPI. When looking back on how this choice was made I tend to agree with Elizabeth Bennett that a good memory is unpardonable, but, is it a problem that there are multiple ways to delete a Record?

Delete via Record post

The first method is to use a service action, that is to post JSON similar to that below to the Record endpoint. Not only does this attempt to delete the Record but also allows you to make updates to properties (and save) the Record prior to delete being called.

{
    "Uri": 9000000544,
    "DeleteRecord": {
        "DeleteRecordDeleteContents": false
    }
}

Delete via delete service

The other way to delete is simply to post to the delete service using a URL like this:

http://localhost/ServiceAPI/Record/rec_364/Delete

And the winner is…

Avoid the first option and use the second option. Why? The first option, in addition to deleting the Record, does all of the processing required when updating properties and fields. This is unnecessary when you are deleting and is likely to cause errors. The second option avoids all the unnecessary pipeline and simply deletes the Record making it much more robust.

Written on February 7, 2019