Update an Instance

To update an instance, perform a PUT on the individual entity, passing a JSON string that contains the fields to be changed.

To update an instance:

  1. Get the list of fields.
    To get the list of fields for an entity, get the Fields metadata.
    Do not use the field list returned by retrieving a single entity. The data returned for an entity may contain calculated fields that cannot be POSTed or PUT.
  2. Create a JSON string that contains the fields to be changed. JSON input must be of the same format as data returned from a GET operation on the entity.
  3. PUT the data to the resource.   
  4. On success, the HTTP return value is 200. The returned string is the complete data of the updated entity.

Caution: It is possible to update all of the instances in a collection if no entity is specified. If you use a query or script to specify the entity, make sure its result is not empty.

For example, this will update the status of all test instances in the project to FAILED:

PUT /qcbin/api/domains/{domain}/projects/{project}/test-instances/ 
{parameter:entity type=test-instance, field name=status, value=FAILED}

Example

Update defect 4
*** Request ***
PUT /qcbin/api/domains/DEFAULT/projects/REST/defects/4 HTTP/1.1
Host: my-server:8081
Connection: keep-alive
Content-Length: 32
Accept: application/json
Origin: chrome-extension://cokgbflfommojglbmbpenpphppikmonn
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,he;q=0.6
Cookie: JSESSIONID=1234567890; hp_last_segment=segment neutral; s_vi=1234567890; hpeuck_answ=0; Remember_me=1234567890; s_fid=1234567890; _HPNNPERSIST=my-user@my.com; SMSESSION=1234567890; JSESSIONID=1234567890; hp_last_segment=segment neutral; s_vi=1234567890; hpeuck_answ=0; Remember_me=1234567890; s_fid=1234567890; _HPNNPERSIST=my-user@my.com; LWSSO_COOKIE_KEY=1234567890; QCSession=1234567890; ALM_USER=1234567890; XSRF-TOKEN=1234567890
{"name": "new name of defect 4"}
*** Response ***
HTTP/1.1 200 OK
Date: Tue, 23 Dec 2014 16:07:46 GMT
Content-Type: application/json
Content-Length: 946
Server: Jetty(9.1.3.v20140225)
{
    "type": "defect",
    "has-change": null,
    "planned-closing-ver": null,
    "test-reference": null,
    "subject": null,
    "reproducible": null,
    "request-id": null,
    "request-server": null,
    "id": 4,
    "ver-stamp": 3,
    "has-others-linkage": "N",
    "description": "<html><body>\n<p>Alternative source of income required.</p> \n</body></html>",
    "priority": null,
    "name": "new name of defect 4",
    "has-linkage": "N",
    "run-reference": null,
    "cycle-reference": null,
    "dev-comments": null,
    "creation-time": "2014-12-23",
    "to-mail": null,
    "request-note": null,
    "closing-version": null,
    "cycle-id": null,
    "detection-version": null,
    "last-modified": "2014-12-23 18:07:46",
    "status": "Fixed",
    "closing-date": null,
    "detected-in-rcyc": null,
    "detected-in-rel": null,
    "severity": "2-Medium",
    "attachment": null,
    "extended-reference": null,
    "estimated-fix-time": null,
    "project": null,
    "target-rel": null,
    "detected-by": "elizabeth",
    "environment": null,
    "step-reference": null,
    "owner": "darcy",
    "target-rcyc": null,
    "actual-fix-time": null,
    "request-type": null
}