Reputation: 171
What kind of HTTP request can be used to get a newly created entity each time?
For example:
<> /point
- each time should return new point instance with random values.
Upvotes: 0
Views: 690
Reputation: 57299
What kind of HTTP request can be used to get a newly created entity each time?
It depends
For example: <> /point - each time should return new point instance with random values.
So one example that does exactly that is the online uuid generator. You send a GET request for the home page, and the representation that comes back has a new UUID in it (along with instructions telling you to refresh the page to get another).
GET
is safe:
the client does not request, and does not expect, any state change on the origin server as a result of applying a safe method to a target resource
The server's implementation isn't constrained, but because the semantics are safe you need to keep in mind that clients may GET
the resource much more often than they need to. The server is responsible for anything that happens which causes loss of property (aka money).
If you want clients to understand that the semantics are unsafe, POST is probably your best choice out of the usual collection of methods. PUT's semantics are those of providing the server with a new representation of a resource, and DELETE is about unlinking the resource from the representation altogether.
If you had a patch document media type that allowed you to express "replace this part of the representation with something random", then HTTP Patch would be a possibility as well.
Upvotes: 1