ben_weller
ben_weller

Reputation: 88

What is the proper RESTful HTTP method for update of unique "slug" for a given record?

Given an existing set of records tied to a given unique identifier (a.k.a. slug), which is a portion of a key for multiple related records, what HTTP method is appropriate for updating such records to a new unique identifier?

OPTIONS, GET, PUT, POST, HEAD, DELETE, TRACE, and CONNECT all seem irrelevant to the functionality in question.

I'm reluctant to create a separate set of URIs that represent the "update slug/identifier" functionality when the URI schema is well established.

Thoughts? Opinions?

Upvotes: 0

Views: 239

Answers (1)

Darrel Miller
Darrel Miller

Reputation: 142202

I'm reluctant to create a separate set of URIs that represent the "update slug/identifier" functionality when the URI schema is well established.

If I am interpreting you correctly then you are going find REST very difficult. In RESTful design, it is very common to have to create new resources to help work around the limited set of methods.

To answer the question directly. I would consider something like,

GET /recordsets/{oldslug}

to retrieve the items you wish to change the slug for and then

POST /recordsets/{newslug}

to assign the new slug to recordsets passed in the body. If for perf reasons you do not want to roundtrip the recordsets you could do,

POST /recordsets/{newslug}?source=/recordsets/{oldslug}

Upvotes: 1

Related Questions