Passing array in GET for a REST call

前端 未结 6 1548
清歌不尽
清歌不尽 2020-12-13 16:56

I have a url to fetch appointments for a user like this:

/user/:userId/appointments

How should the url look like if I want to get appointme

6条回答
  •  臣服心动
    2020-12-13 17:41

    Another way of doing that, which can make sense depending on your server architecture/framework of choice, is to repeat the same argument over and over again. Something like this:

    /appointments?users=id1&users=id2
    

    In this case I recommend using the parameter name in singular:

    /appointments?user=id1&user=id2
    

    This is supported natively by frameworks such as Jersey (for Java). Take a look on this question for more details.

提交回复
热议问题