title: When is JSON-RPC over http with POST more suitable than RESTful API?
body: <p>I'm currently developing a web application with a senior developer. We've agreed to use REST API for client-server communication and he sent me the parameters and the expected responses.</p>
  
  <p>But the design does not seem to be RESTful. Rather it looks like JSON-RPC over http utilizing only the POST method.</p>
  
  <p>For example, to register a user you send a POST request to the server the following parameters. </p>
  
  <pre><code>{
    id: 1,
    method: "RegisterUser",
    params: {
      firstName: "John",
      lastName: 'Smith',
      country: 'USA',
      phone: "~",
      email: "~",
      password: "~"
    }
  }
  </code></pre>
  
  <p>And the expected response is </p>
  
  <pre><code>{
    id: 1
    result: "jwt-token",
    error : null 
  }
  </code></pre>
  
  <p><em>Multiple requests are sent to the same URL and the server sends back the response based on the 'method' in the parameters. For example, to get a user info, you send a <code>{ method: "GetUserInfo", params: { id: ~ }}</code> to the same URL. All responses have the status code 200, and the errors are handled by the error in the response body. So even if the status code is 200, if error is not null it means something is wrong.</em></p>
  
  <p>The way I'm used to doing is sending a POST request to 'users/' with a request body when registering a new user, sending a GET request to 'users/1' to retrieve a user information, etc.</p>
  
  <p>When I asked why he'd decided to do it this way, he said in his previous job, trying to add more and more APIs was a pain when following RESTful API design. Also, he said he didn't understand why RESTful API uses different HTTP verbs when all of them could be done with POST.</p>
  
  <p>I tried to come up with the pros of REST API over JSON-RPC over http with POST.</p>
  
  <ol>
  <li><p>GET requests are cached by the browser, but some browsers may not support POST request caching.</p></li>
  <li><p>If we are going to open the API to outside developers, this might cause discomfort for them since this is not a typical REST API.</p></li>
  </ol>
  
  <p>In what circumstance would the JSON-RPC over http style be better the REST RESTful APIs? Or does it just not matter and just a matter of preferance?</p>