Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Interesting answer! For your last example, wouldn't it be more consistent with the [GET] format to do [PATCH] mail?markAsRead=true data: [{"id": 1}, {"id": 2}, {"id": 3}] (or even just data: {"ids": [1,2,3]})? Another benefit to this alternate approach is that you won't run up against "414 Request URI too long" errors if you're updating hundreds/thousands of resources in the collection. Commented Aug 22, 2016 at 23:40
  • @rinogo - actually no. This is the point I was making. The querystring is a filter for the records we want to act upon (eg. [GET] mail/1 gets the mail record with an id of 1, whereas [GET] mail?markasRead=true returns mail where markAsRead is already true). It makes no sense to patch to that same URL (ie. "patch the records where markAsRead=true") when in fact we want to patch particular records with ids 1,2,3, REGARDLESS of the current status of the field markAsRead. Hence the method I described. Agree there is a problem with updating many records. I'd build a less tightly coupled endpoint. Commented Aug 24, 2016 at 0:23
  • Unfortunately, this breaks down as you approach URL string max length, considering resource IDs are typically 20+ character UIDs. Updating for example a flag or status on a large number of records is a common requirement. Commented Mar 22, 2022 at 19:34