1

I've come across a situation in my webservice where in I've to delete a resource and update the other resources which are referring to this resource with other resource specified by user. How can I achieve this in RESTful way?

For example: DELETE resource Agent/123 Some customers might be assigned to this agent, hence while deleting the Agent 123 user will specify another agent 125 for all these customers.

I thought of following ways:

DELETE request on the url Agent/123/125 On the server I'll handle this request at url Agent/123 and new agent id will be taken as 125. I felt this is completely away from RESTful way, so thought of dropping this idea. Please let me know whether this restful way.

Another option is: Delete Agent/123?ReAssignId=125

I'm not sure whether this is also restful way or not, I've come across this method in this question. I'm still not convinced with this strategy as well.

Have any one come across this situation, how this situation should be handled in Restful way?

3 Answers 3

1

FWIW, I like the option Delete Agent/123?ReAssignId=125 because the reassignment number is just a metavalue associated with the delete operation. The core operation is a delete (resource gets removed and is no longer available).

Sign up to request clarification or add additional context in comments.

Comments

0

This sounds more like an UPDATE operation and a DELETE later on when the new agent has been asigned for the customer(s). If both methods have to be somewhat atomic, I think the best REST-ful way would be to organize this on client.

2 Comments

You mean two requests should be sent to server for this operation. I was trying to avoid two requests to the server.
Also two requests means that the data will temporarily be in an inconsistent state.
0

To be truly RESTful, you'll have to individually update each Customer resource, then delete the Agent. But if you've realized that this is all more of a guideline than anything else, I really don't see any reason why you wouldn't use your ReAssignId technique.

1 Comment

What REST constraint is he violating?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.