6

Currently, I'm using a POST-request to my Web API when I want to get data, rather then a GET-request, because the parameter that I'm sending, exceeds the URL-limit.

However, it's bad practice to use POST when you want to get data.

What is the correct way to do it when you have parameters that exceeds the URL limit and you must use POST instead of GET?

halfer
  • 19,824
  • 17
  • 99
  • 186
Bryan
  • 3,421
  • 8
  • 37
  • 77
  • this exposes a greater underlying problem of the amount of details needed to be sent in order to get a response. This appears to be an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). A [mcve] should help clarify the actual problem – Nkosi Jun 19 '18 at 11:23
  • Also, this similar question might be relevant: https://stackoverflow.com/questions/5947414/using-post-as-a-workaround-for-the-url-character-limit – Anorionil Jun 19 '18 at 11:26
  • 3
    "However, it's bad practice to use POST when you want to get data." No, it isn't. – Eric Stein Jun 19 '18 at 13:21
  • 1
    @EricStein: When you google, the majority says it is. – Bryan Jun 20 '18 at 07:01
  • 1
    @Bryan I prefer to follow the HTTP spec, rather than following people who haven't read it but think they know what it says. – Eric Stein Jun 20 '18 at 13:43
  • 3
    GET is *preferable* because it is both safe and idempotent. However, if GET does not work (as in your use case), the fallback is to use POST. If POST was not intended to support returning data, the HTTP spec would forbid a response body. It does not. – Eric Stein Jun 20 '18 at 14:01
  • @EricStein: That's true. Can you link any resource regarding the HTTP spec about POSt? – Bryan Jun 21 '18 at 06:31
  • https://tools.ietf.org/html/rfc7231#section-4.3.3 – Eric Stein Jun 21 '18 at 11:43

0 Answers0