REST API using POST instead of GET

前端 未结 8 794
野趣味
野趣味 2020-12-04 07:17

Let\'s assume a service offers some funcionality that I can use like this:

GET /service/function?param1=value1¶m2=value2

Is it righ

8条回答
  •  隐瞒了意图╮
    2020-12-04 07:49

    POST is valid to use instead of GET if you have specific reasons for doing so and process it properly. I understand it's not specifically RESTy, but if you have a bunch of spaces and ampersands and slashes and so on in your data [eg a product model like Amazon] then trying to encode and decode this can be more trouble than it's worth instead of just pre-jsonifying it. Make sure though that you return the proper response codes and heavily comment what you're doing because it's not a typical use case of POST.

提交回复
热议问题