REST API using POST instead of GET

前端 未结 8 788
野趣味
野趣味 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:59

    In REST, each HTTP verbs has its place and meaning.

    For example,

    • GET is to get the 'resource(s)' that is pointed to in the URL.

    • POST is to instructure the backend to 'create' a resource of the 'type' pointed to in the URL. You can supplement the POST operation with parameters or additional data in the body of the POST call.

    In you case, since you are interested in 'getting' the info using query, thus it should be a GET operation instead of a POST operation.

    This wiki may help to further clarify things.

    Hope this help!

提交回复
热议问题