Primary Keys for RESTful Web Services

When calling RESTful web services, the primary key of the item you are querying or updating is normally part of the URL.
Two issues may crop up:

Primary keys with reserved characters

Numeric primary keys are fine, but if your primary key is a string, you need to think about what happens when the string contains a reserved character, such as the forward slash '/'.

If the primary key always contains a forward slash, then effectively you have two parts of the URL forming the primary key.
Otherwise, you will need to consider URL-encoding the primary key.

In C# the resolver is setup by default to automatically allow the primary key to be passed as the id parameter.
So instead of:

https://www.server.com/api/books/12

You can use this URL:

https://www.server.com/api/books?id="12/A"

Composite primary keys

Sometimes the database table you are writing a web service for does not have a single column that forms the primary key; there may be two or more columns in the primary key, such as a book id and a chapter number within the book.
In this case you will need to supply values for both the columns. It is probably best to supply the key for the "larger" object first, e.g. the book's id followed by the chapter number:

https://www.server.com/api/books/137/chapter/3