0

Does Json Patch violate REST rules? My API won't be RESTful if I use it? Or, maybe not?

{ "op": "replace", "path": "/biscuits/0/name", "value": "Chocolate Digestive" }
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Why do you think so? Your quoted example stems of a well-defined media-type, [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902), which defines the syntax and semantics of each of the elements that may occur in such a document. A client may produce such a response as part of a form-response where the form is feed with the current version of a resource and the client is smart enough to calculate the necessary changes between the state as given by the server and the one the clients wants to send. – Roman Vottner Aug 19 '21 at 15:54
  • It was only a question. – Andrea Bocieli Aug 19 '21 at 16:30

1 Answers1

1

Does Json Patch violate REST rules?

No.

JSON Patch is a standardized media-type designed to act as a patch document (in the RFC 5789 sense). It is a perfectly normal way to describe edits to a JSON document.

Every protocol, every media type definition, every URI scheme, and every link relationship type constitutes prior knowledge that the client must know (or learn) in order to make use of that knowledge. REST doesn’t eliminate the need for a clue. What REST does is concentrate that need for prior knowledge into readily standardizable forms. -- Fielding, 2008

And that's exactly what has been done here.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91