REST is the new SOAP
&gt; <i>You want to use PUT to update your resource? OK, but some Holy Specifications state that the data input has to be a “complete resource”, i.e follow the same schema as the corresponding GET output.</i><p>If you were working in a strongly typed language with RPC calls, you would see the same problems, or symptoms thereof. For example, if you had the two RPC calls storeFoo and retrieveFoo, you&#x27;d expect them to both take Foo objects, no? Something like,<p><pre><code>  storeFoo(name: String, foo: Foo)
  retrieveFoo(name: String) -&gt; Foo
</code></pre>
and PUT&#x2F;GET in HTTP yearns for the same dichotomy.<p>&gt; <i>So what do you do with the numerous read-only parameters returned by GET (creation time, last update time, server-generated token…)? You omit them and violate the PUT principles?</i><p>Yes, and just call it POST, since it&#x27;s no longer symmetric and violates PUT principles. REST has nothing against POST. Again, this problem would be reflected similarly in RPC:<p><pre><code>  storeFoo(name: String, foo: PartialFoo)
  retrieveFoo(name: String) -&gt; Foo
</code></pre>
(or perhaps storeFoo ignores some fields on Foo, etc.)<p>&gt; <i>creation time</i><p>This is a fantastic example, because I actually had this problem w&#x2F; a non-RESTful API. We took a generic sort of &quot;create record&quot; and recorded the current time as the &quot;start&quot; time. The problem was when the device lost network connectivity (which was essentially always, just a matter of &quot;how bad <i>is</i> the latency): the creation of the record would lag, sometimes by <i>hours</i>, and the eventual &quot;creation time&quot; it was tagged with was <i>wrong</i>. We should have trusted the device, because it knew much better than the server when the actual record was created.<p>Now, this isn&#x27;t going to be the case all the time; sometimes you literally want just the time the DB INSERT statement happened, and that&#x27;s fine.<p>&gt; <i>Pick your poison, REST clearly has no clue what a read-only attribute it</i><p>POST a &quot;create&quot; request, GET has the newly created fields. Symmetric PUT&#x2F;GET is nice, but show me where in HTTP it is recorded as an absolute.<p>&gt; <i>Meanwhile, a GET is dangerously supposed to return the password (or credit card number)</i><p>Not only does REST not dictate this, nobody in their right mind should do this. GETs just return the resource. What that resource is, what data is represented — that&#x27;s up to you in HTTP just as it is in RPC.<p>&gt; <i>lots of resource parameters are deeply linked or mutually exclusive(ex. it’s either credit card OR paypal token, in a user’s billing info)</i><p>If your request looks like,<p><pre><code>  &quot;paypal_token&quot;: ...
  &quot;credit_card&quot;: ...
</code></pre>
Then your RPC would look like,<p><pre><code>  struct PaymentDetails {
    paypal_token: ...
    credit_card: ...
  }

  updatePaymentDetails(..., new_details: PaymentDetails)
</code></pre>
and you&#x27;re in the same hot water, again, just with RPC. If your type system allows it, you can make them mutually exclusive there, perhaps something like,<p><pre><code>  enum PaymentDetails {
    Paypal(token),
    CreditCard(card_number),
  }
</code></pre>
but then, that cleanly translates back into a RESTful API&#x27;s information too. Now, JSON is typically used, and it doesn&#x27;t really expose a real sum type, which is a shame. You can work around it w&#x2F; something like,<p><pre><code>  &quot;payment_details&quot;: {
    &quot;type&quot;: &quot;paypal&quot;,
    &quot;token&quot;: ...,
  }
</code></pre>
and it works well enough. If you can&#x27;t express it in the type system (in <i>either</i> RPC or REST) then you have to do some validation, but that&#x27;s true regardless of whether RPC or REST is in use.<p>&gt; <i>you’d violate specs once more: PATCH is not supposed to send a bunch of fields to be overridden</i><p>…how is that a violation of the spec?<p>&gt; <i>The PATCH method requests that a set of changes described in the request entity be applied to the resource</i><p>&gt; <i>With PATCH, however, the enclosed entity contains a set of instructions describing how a resource currently residing on the origin server should be modified to produce a new version.</i><p>That&#x27;s exactly what sending a subset of fields <i>is</i>. It&#x27;s an adhoc new media type describing a set of changes.<p>&gt; <i>So here you go again, take your paperboard and your coffee mug, you’ll have to specify how to express these instructions, and their semantics.</i><p>No more than you would an RPC call, AFAICT. E.g.,<p><pre><code>  updateFoo(
    field_a_new_value: Optional&lt;...&gt;,
    field_b_new_value: Optional&lt;...&gt;,
  )
</code></pre>
<i>etc.</i> is really no different.<p>&gt; <i>OK, but I hope you don’t need to provide substantial context data; like a PDF scan of the termination request from the user.</i><p>If it&#x27;s not a simple &quot;delete this thing&quot;, that&#x27;s fine. POST is still there.<p>&gt; * For exemple, lots of developers use PUT to create a resource directly on its final URL (&#x2F;myresourcebase&#x2F;myresourceid), whereas the “good way” of doing it is to POST on a parent URL (&#x2F;myresourcebase), and let the server indicate, with an HTTP redirection, the new resource’s URL.*<p>Either is fine.<p>&gt; <i>Using “HTTP 401 Unauthorized” when a user doesn’t have access credentials to a third-party service sounds acceptable, doesn’t it? However, if an ajax call in your Safari browser gets this error code, it’ll startle your end customer with a very unexpected password prompt.</i><p><i>Only</i> if you accept Basic authentication, and indicate that in your headers. It is, I agree, somewhat unfortunate that the browsers do not let you control this behavior. I don&#x27;t feel that this is an issue for many people these days. (If you&#x27;re using something like a JWT, you&#x27;re not going to hit this, since you&#x27;ll likely be using something like Bearer for an authentication scheme.)<p>&gt; <i>Or you’ll shamelessly return “HTTP 400 Bad Request” for all functional errors, and then invent your own clunky error format, with booleans, integer codes, slugs, and translated messages stuffed into an arbitrary payload.</i><p>Would you not need to stuff that information into some form of error or exception type in the RPC world? (The error &quot;code&quot; might be standardized, e.g., JSONRPC does this, but the associated data cannot be.) But unless you clearly fall into one of the predefined categories, and even if you <i>do</i>, it doesn&#x27;t hurt to settle on a standard &quot;error&quot; type&#x2F;format.<p>REST is about talking about the resources, about defining formats &#x2F; objects that clearly indicate whatever state&#x2F;data they represent. For most people, this is &quot;just&quot; going to be a JSON document, but all too often you see the same <i>concept</i> or state expressed five different ways in not-RESTful APIs. For example, a ZIP code that is sometimes just a string, sometimes a {&quot;zip_code&quot;: &quot;12345} sometimes a {&quot;zip&quot;: 12345}; the author here is failing to understand that a common type exists, and that he should form an actual format around it that he can refer to globally (this field is a <i>zip</i> — and we defined that <i>here</i> and we know it always looks the same, always.)<p>Frankly, I feel like most of that issue is from JavaScript and JSON, since both discourage any form of static typing of data, and humans naturally just get the immediate job done, but at the cost of having the same concept expressed six different ways.<p>&gt; <i>Or, well, yes, actually it remember its authentication session, its access permissions… but it’s stateless, nonetheless. Or more precisely, just as stateless as any HTTP-based protocol, like simple RPC mentioned previously.</i><p>This isn&#x27;t what &quot;stateless&quot; refers to. It&#x27;s <i>stateless</i> in that the requests are (generally speaking) independent of each other. One might need authentication, and you might have to get that somewhere, and that might need a request, yes. Store data of course changes the state of the server. But you can disconnect and reconnect and reissue that next request without caring.<p>&gt; <i>The split of data between “resources”, each instance on its own endpoint, naturally leads to the N+1 Query problem.</i><p>It can, but again, doesn&#x27;t need to, and is no more susceptible to this than an RPC API. In an RPC API, you still need to determine what to expose, and how many API calls and round trips that will require…<p>&gt; <i>“The client does not need any prior knowledge of the service in order to use it”. This is by far my favourite quote. I’ve found it numerous times, under different forms, especially when the buzzword HATEOAS lurked around;</i><p>I feel like this was expressed by Fieldings to encapsulate two ideas:<p>* You can push code, on demand.<p>* You can refer to associated resources, or even state transitions, via hyperlinks.<p>Most supposedly (but not really) RESTful APIs do neither, so it&#x27;s entirely a moot point. I think people <i>way</i> over read this to mean <i>absolutely</i> no prior knowledge, whereas Fieldings intended it to mean something closer to &quot;only knowledge of the media types being returned&quot;, which is actually quite a bit of prior knowledge. But the two bullets above still allow you to encode a considerable amount of flexibility into an API, considerably more than something that ignores those points.<p>Frankly, I feel like if you start with an RPC protocol, you&#x27;ll eventually want some stuff: caching. Retries would be nice, but you need to know if you <i>can</i> retry the operation. Metadata (headers). Partial requests. Pagination. Can you encode all of this with RPC protocols? Absolutely! But it comes up so often, it would be nice to standardize it, and many of these things (caching, pagination, range requests) get a lot easier if you stop talking about operations and start talking about the data (resources) being operated on, which is — to me — the big &quot;ah ha!&quot; of HTTP, and why HTTP is what it is today. That is, HTTP <i>is</i> a highly evolved RPC protocol.