Previous Page Arrow Next Page Arrow

2.2 Single Resource URL

The URL for a single resource is obtained by appending a resource selector to a resource collection URL. For example:

 http://www.example.com/sdata/myApp/myContract/-/accounts('A001')
Example Component Name Description / Comments
('A001') Resource selector This element identifies a single resource. The value between the quotes is the primary key of the resource.

This URL returns the account resource as an Atom entry.

The resource selector MAY contain a clause - a Boolean expression. This makes it possible to identify a resource by a criteria other than its primary key, which maybe helpful in mashup scenarios. For example, the following URL identifies an account by its taxID:

http://www.example.com/sdata/myApp/myContract/-/accounts(taxID eq '1234')

With this syntax, the clause MUST match a single resource. If the clause matches more than one resource, the service MUST return a 400 Bad Request HTTP status code.

The isUniqueKey schema attribute MAY be used to test whether a given property identifies resources in a unique way or not. See Metadata Extension section.

If the parenthesized contents starts with a single quote, it MUST be interpreted as a primary key value. Otherwise, it MUST be interpreted as a clause. See Query Language section.

If resources are identified by a composite primary key, the key components MUST be formatted as a single parameter in the URL. For example if accounts are identified by the combination of a letter (C for customers or P for providers) and a numeric id, the letter and numeric id MUST be combined to form a single parameter. For example accounts(‘C;257’).

At this level the syntax is not imposed by SData. The application is free to choose whatever delimiter is the most appropriate, and eventually provide an escaping mechanism for the delimiter. So, the use of a semicolon is not imposed by SData.

SData URLs for single resources MUST comply with this syntax. The primary key selector syntax (accounts('A001') MUST be supported. The Boolean clause syntax (accounts(taxID eq '1234')) SHOULD be supported with at least the basic query syntax described in the Query Language section.

Previous Page Arrow Next Page Arrow