8

Simple question: what if I'm NOT sending data (content) via HTTP POST/PUT method on my resource — is it still RESTful?

Obviously, the question is in which case would I want use PUT without data. Imagine a user that wants to reset his/her password (like in this older topic).

What do you think of it? Is it okay NOT to send content with POST/PUT methods? Personally I have no problem with it but I'm just curious what would other people say.

2 Answers 2

5

Yes, this is perfectly acceptable. Each action (POST to a collection, PUT to a resource) when performed with no data should create a new, "empty" resource. The definition of "empty" here would depend on what is being represented.

In the specific case of resetting a user's password, however, I wouldn't say that the above model applies. If there truly is a password resource, a PUT with no data would seem to suggest setting the password to be empty, rather than resetting it. For this scenario, I'd go with the accepted answer from that question.

3

You don't need data in a POST or PUT for it to be Restful. If you are doing something is non-Idempotent (meaning the request will modify or create a resource), you don't want to use GET (whether there is any data to pass or not). For example, you might have a RESTful web service that considers the time of the request and the resource url hit as all it needs to create or modify some resource--no request data needed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.