Just a quick question. Which one of the following makes a better Rest API Url & why so?

  1. GET shop/department/{id}/{action}
  2. GET shop/department/{action}/{id}

The action is a verb and it can be:

  • GET shop/department/{id}/download
  • GET shop/department/{id}
  • GET shop/department/{id}/receive
有帮助吗?

解决方案

If action is an action as in Remote Procedure Call RPC, both are equally bad.

Actions don't belong in URLs but in HTTP verbs.

其他提示

Use actions and corresponding id as parameter

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top