Reputation: 411
I have a REST endpoint in my application that takes no data and returns no data. The endpoint is clearing out some data I previously stored in the user's session. I don't need to send or receive data from the client -- just hit the endpoint.
I currently allow the endpoint to only receive HTTP POST requests.
Is there a better HTTP request method than POST for this scenario? If so why?
Upvotes: 0
Views: 572
Reputation: 6606
I think this is actually fine. POST
doesn't necessarily need to create a resource. If it's modifying the client's session, it's ok in my book. For the return code, consider 204/No content
.
Upvotes: 1
Reputation: 411
The endpoint is not actually ReSTful. Clearing out session data means your aren't transferring state on each request, see If REST applications are supposed to be stateless, how do you manage sessions?
Upvotes: 0