Reputation: 47
It's a just curiosity. If it's really bad practice to mix query and body params in POST request.
Just for example:
/someservice/create/{id}?idApp=989898
RequestBody: {par1: par1, par2: par2}
Upvotes: 1
Views: 2230
Reputation: 1075189
Oversimplifying, the URI is there to identify the resource and the request body is there so you can send information with the request. So for instance:
POST /modify/whatsit?id=123 Body: Data for modifying the whatsit
is fine. The URI is saying what to modify (whatsit 123), and the body is the information for that.
Your example uses create
in the URI, so I wouldn't expect it to also have an idApp
parameter, since IDs are normally assigned as/when the item is created. So in that particular example, I wouldn't expect to find query parameters in the URI. I'd normally expect any additional information for the create
operation to be in the request body.
That said, sometimes people put the identifying information in the request body instead. One advantage to having it in the URI is that logs containing the URI but not the post body tell you not just that a resource was modified (/modify/whatsit
), but which resource was modified (/modify/whatsit?id=123
).
Upvotes: 4