Search code examples
httpgetrestflask-restful

HTTP GET for a large string payload


I have a requirement where I need to make a HTTP request to a Flask server where the payload is a question(string) and a paragraph(string). The server uses machine learning to find the answer to the question within the paragraph and return it.

Now, the paragraph can be huge, as in thousands of words. So will a GET request with a JSON payload be appropriate? or should I be using POST?


Solution

  • will a GET request with a JSON payload be appropriate?

    No - the problem here is that the payload of a GET request has no defined semantics; you have no guarantees that intermediate components will do the right thing with your request.

    For example: caches are going to assume that the payload of the request is irrelevant, so your GET request might get a response for a completely different document.

    should I be using POST?

    Today, you should be using POST.

    Eventually, you'll probably end up using the safe-method-with-body, once the HTTP-WG figures out the semantics of the new method and adoption has taken hold.