fields Clause: Selecting Fields to Return

Description

Specifies the fields to be returned in the response to a GET operation on a collection.

Applies To

GET method on collections and instances.

Remarks

If the fields clause is sent, the response contains the data for the specified fields and for some fields that are returned unconditionally. Which fields are returned unconditionally varies depending on the resource.

If the fields clause is not sent, all fields are returned.

Limiting the returned data to those fields required by your application and the unconditionally returned fields may significantly improve performance.

A fields clause has the following syntax: fields=<field name>[[,<field name>]]. Field names are separated by a comma (,).

To specify a field, use the "name" value returned in the fields metadata. See Fields.

Limitations

See Limitations section of Defects

Example

GET defect with fields clause
****  Request ****
GET /qcbin/api/domains/DEFAULT/projects/REST/defects?fields=id,name,description 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 10:48:23 GMT
Set-Cookie: LWSSO_COOKIE_KEY=1234567890;Path=/;HTTPOnly
Cache-Control: no-cache, max-age=0
Pragma: no-cache
Content-Type: application/json
Vary: Accept-Encoding, User-Agent
Content-Length: 350
Server: Jetty(9.1.3.v20140225)
{
    "data": [
        {
            "type": "defect",
            "id": 2,
            "description": "<html><body>\n<p>Were headed for Scotland, but went to London, instead.</p> \n</body></html>",
            "name": "Lydia in London with Wickham"
        }, {
            "type": "defect",
            "id": 3,
            "description": "<html><body>\n<p>Pequod dumping whale oil to continue chase.</p> \n</body></html>",
            "name": "White whale elusive"
        }, {
            "type": "defect",
            "id": 4,
            "description": "<html><body>\n<p>Alternative source of income required.</p> \n</body></html>",
            "name": "Estate entailed to Collins"
        }, {
            "type": "defect",
            "id": 6,
            "description": "<html><body>\nRefuses to acknowledge her.\n</body></html>",
            "name": "Willoughby disaffected with Marianne"
        }
    ]
}