• Post Reply Bookmark Topic Watch Topic
  • New Topic

Updating a key field in a RESTful web service  RSS feed

 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a subscriber registry with a RESTful web service interface to be used by external applications. Subscribers are uniquely identified by their IMSI.

What I am trying to figure-out is if I want to allow the IMSI to be changed, what would be the best method for the request, and what would be a proper response.

My current thinking is:
   - POST is not correct since a new resource is not be created
   - PUT is not correct since an entire resource is not being replaced
   - PATCH is correct since less than the entire resource is being updated

   - include a Location header is in the response which identifies the new location for the subscriber resource
   - use 201 status code to indicate success since clients may already understand that a new location will be provided with a 201

Request:
PATCH /hss/sub/imsi/123456789012345
{
   "imsi":"123456789098765"
}


Response:
201 Updated
Location: /hss/sub/imsi/123456789098765


Does this seem like the good approach? Any comments or suggestions?
 
Simon Roberts
Author
Ranch Hand
Posts: 176
9
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that from a philosophical perspective, if you are creating a new primary key, you're creating a new record. That's POST. The problem is, you're really concurrently adding a new one and deleting the old. That's a PATCH. But in practice, if you really must do this (which I will admit seems to me, from the outside to be little short of sick and wrong! ) I think the clearest parallel is with updating, and that's a PUT.

Sorry, that probably doesn't help, but it might trigger more opinions!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!