So the recommendations for using GET vs POST in a REST API that I've read on stack overflow are geared almost exclusively toward CRUD operations involving a database.
However if you are simply writing the API to expose a machine learning model to serve predictions, most of the examples I've seen online use POST requests without explaining why they use it as opposed to a GET request.
From my perspective a GET request can serve the same purpose because if my prediction method requires some sort of data that will never be placed in the URL (like a json string), I can send it in the body of the GET request the same way I can with a POST request. I'm also not modifying anything on the server with the GET request.
Regarding idempotency, the model prediction should return the same result if a request containing the same input parameters is sent multiple times, making GET in this case idempotent.
So my question is, in this specific scenario - exposing machine learning models, or other functionality not involving any database - is there any reason why I would use a POST request instead of a GET?
Or could you use these interchangeably in this scenario without any difference?
GET
must be 'safe' which is a more stringent requirement than idempotent. That is: all 'safe' operations are idempotent but not all idempotent operations are 'safe'.if my prediction method requires some sort of data that will never be placed in the URL (like a JSON string)
. Really? Why? Because of the length of the Json|URI? The encoding?