user1693999
user1693999

Reputation: 21

What would be the appropriate HTTP method to rename a resource in RESTful APIs

Will we use PUT or POST when the identity of resource itself is changing from oldname to newname in the web service?

Upvotes: 2

Views: 1720

Answers (2)

Joyal George
Joyal George

Reputation: 590

You can use PATCH request to update data in webservice.

POST means create new and PUT means insert, replace if already exists.

Find more details - click here

Upvotes: 1

Opal
Opal

Reputation: 84854

Typically POST is used to create a resource. Since you're not creating a resource better option seems to be PUT but... PUT request are idempotent - it means more or less - repeatable in terms of outcome, further reading might be found here. Also PUT needs to contain the whole resource. Thus, maybe PATCH is the right choice?

Upvotes: 2

Related Questions