0

Scenario: We are creating/desiging a REST service to help us configure a system (and it's network, etc), but we run into some problems related to designing this API. We would like to configure the hostname of the system using a REST call/

Challenge: Because most APIs and design guidelines are related to lists of entities and not just a single one, I can't decide on how the rest API should look like.

Currently we are considering using something like:

  • GET /system/0
  • PUT /system/0 {....}

Problem: There is just one system entity so it doesn't feel good to identify this using 0 because there is only one of it.

Are there any REST guidlines about how this should be done?

Community
  • 1
  • 1
Raymond Domingo
  • 173
  • 2
  • 9

1 Answers1

0

Actually, REST does not enforce a particular format for the URL, you can even have an URL like /569284d7-1b59-4343-92d4-90e8753bcbd7 and it's OK. In REST the server guides the client through state changes, it's not about the client knowing what URLs to access.

Most web API's are created in a CRUD style, with hierarchies of resources like your example /system/0, /system/1 because it's easier to understand and implement (might not always be RESTful depending on how tight the coupling of the client is to the URLs, but it serves most needs so people chose to do it like that).

So my advice would be to keep it simple and not over-think it. Using /system/0 is just fine, even if now you have only one system.

Just my 2 cents!

Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • Thank you for sharing. Since we started using spring data jpa rest framework where framework provides crud like rest services, we discovered they use exact same url semantics by default... this will probably the way we will go. – Raymond Domingo Aug 29 '14 at 08:58