Is it bad practice to issue the following POST request:
/test?a=1&b=2
POST data: c=3&d=4
Notice that 2 parameters are part of the URL and 2 parameters are part of the POST content.
On another note, is the following rule still recommended:
- GET request: retrieve content from
the server but do not change anything
on the server. - POST request: post
content to the server which may
modify data on the server
I am asking because I see a bit of everything online.
Laurent Luce
Yes, your assumptions are correct. You should be consistent on how you pass your parameters or require the parameters to be passed, but it’s not going to do any harm really.
GET operations are supposed to be safe operations, that don’t perform any side-effects (besides caching, etc), so they are easily cached by proxies and such. POST operations on the other hand may encure side effects.
I would recommend reading the Wikipedia entry on HTTP protocol:
There are other operations too (e.g. HEAD, PUT, DELETE), and you should consider using them if you are designing an API. These are heavily discussed in RESTful API design.