0

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
Obaid
  • 1,407
  • 19
  • 36

2 Answers2

2

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.

  • 1
    A resource is 'any information that can be named'. 'download' seems a poor name for some information ;) – Michael Brown Sep 25 '12 at 13:31
  • That's why I asked :) I fear that the order of the path elements will not matter for Resources that are totally un-RESTful. –  Sep 25 '12 at 13:32
  • @MichaelBrown I agree, 'download' is indeed a very unRestful. I don't know how I came up with it. – Obaid Sep 25 '12 at 17:05
  • @Obaid Would you please explain what the new path element `receive` means? How does it identify a Resource? –  Sep 25 '12 at 17:14
  • @Tichodroma, `receive` is not a resource, its more of an action that can be performed on the `department` apart from the usual verbs. (I know receive a department sound weird, but its just an example) – Obaid Sep 25 '12 at 17:22
  • @Obaid URIs are idenify Resources. Verbs have no place in URIs. –  Sep 25 '12 at 18:38
0

Use actions and corresponding id as parameter

prady00
  • 721
  • 1
  • 6
  • 17