order-by clause: Sort results
Description
Sorts the returned items.
Applies To
GET on collections.
Remarks
The order clause has the following syntax: order-by=[<direction>]<field name>[[,[<direction>]<field name>]]
.
Field names are separated by commas: ",".
The direction is either "+" (ascending) or "-" (descending). The default is ascending.
Results can be sorted by any fields of the entity.
If no order-by clause is sent, the collection is sorted by entity ID.
Limitations
See Limitations section of Defects
Example
Order by |
---|
*** Request *** GET /qcbin/api/domains/DEFAULT/projects/REST/defects?fields=id,name,status&order-by=name,-status HTTP/1.1 Host: my-server:8080 Connection: keep-alive Accept: application/json User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8,he;q=0.6 Cookie: JSESSIONID=1234567890;lang=EN; cc=EN; Remember_me=1234567890; _HPNNPERSIST=my_user@my.com; XSRF-TOKEN=1234567890; QCSession=1234567890; ALM_USER=1234567890; LWSSO_COOKIE_KEY=1234567890 *** Response *** HTTP/1.1 200 OK Date: Tue, 23 Dec 2014 14:44:06 GMT Set-Cookie: LWSSO_COOKIE_KEY=1234567890;Path=/;HTTPOnly Cache-Control: no-cache, max-age=0 Pragma: no-cache Content-Type: application/json Content-Encoding: gzip Vary: Accept-Encoding, User-Agent Content-Length: 170 Server: Jetty(9.1.3.v20140225) { "data": [ { "type": "defect", "id": 4, "status": "Fixed", "name": "Estate entailed to Collins" }, { "type": "defect", "id": 2, "status": "New", "name": "Lydia in London with Wickham" }, { "type": "defect", "id": 3, "status": "Open", "name": "White whale elusive" } ], "total-count": 3 } |
Working_With