unvadim
unvadim

Reputation: 423

How to model the consequences of HTTP DELETE action without actually doing it

For an HTTP API design I need to allow the user the ability to obtain a list of changes that the HTTP DELETE call on a resource could trigger. i.e. if the resource is a parent in an one to many relationship I would need to reply with the child list. The idea behind this is that the client could use this information to confirm destructive changes before actually making them.

So if actual action would be a simple HTTP DELETE /resources/uuid

Would HTTP DELETE /resources/uuid?simulate=true be acceptable, what would be an appropriate http status code in this case ?

I am interested to know what is the best approach for this scenario of DELETE in two steps.

Upvotes: 2

Views: 201

Answers (1)

Reputationaire
Reputationaire

Reputation: 161

I don't think there's a problem with the approach. One thing that you could consider is when you have multiple APIs that need to be "simulated", it might be worth thinking about a general approach.

You could potentially have something like

DELETE /dryRun/resources/uuid

OR

DELETE /resources/uuid/dryRun

The advantage of having it as a path parameter instead of a query parameter is separation of concerns. You will avoid having if-else in your code with this approach.

Upvotes: 6

Related Questions