Is it considered bad practice to perform an HTTP POST without an object body?

I need to call a process that does not require user input, only a trigger. I plan to use a POST / URI without a body to start the process. I want to know if this is considered bad in terms of HTTP and REST?

+129
rest post
Nov 16 2018-10-10T00:
source share
6 answers

I asked this question to the IETF HTTP working group a few months ago. Short answer: NO, this is not a bad practice (but I suggest reading the thread for more details).

+110
Nov 17 '10 at 19:35
source

Using POST instead of GET is quite reasonable, as it also instructs the server (and gateways along the way) not to return a cached response.

+66
Nov 16 '10 at 6:05
source

POST is completely fine. Unlike GET with POST, you change the state of the system (most likely, your trigger “does something” and changes data).

I used POST without the payload, and it feels OK. One thing you should do when using POST without payload: Pass header Content-Length: 0 . I remember problems with some proxies when api-client did not pass it.

+41
Nov 16 '10 at 21:07
source

If you use POST / uri without a body, it is something like using a function that does not accept the argument .eg int post (void); therefore, it is reasonable to have a function for your resource class that can change the state of an object without an argument. If you think Unix touch is used for URIs, is that not the best choice?

+14
Nov 16 '10 at 7:30
source

I used Post instead of Get, because the operation will change the state of the data, in some cases the operation will create child or nested objects.

0
May 21 '19 at 16:46
source

Yes, it’s normal to send a POST request without a body and use query string parameters instead. But be careful, if your parameters contain characters that are not valid HTTP, you will have to encode them.

For example, if you need to POST 'hello world' to the endpoint, you should make it look like this: http://api.com?param=hello%20world

0
Jul 09 '19 at 1:54
source



All Articles