Create an Instance

To create an instance, perform a POST on the collection, passing a JSON string that contains at least the required fields.

Creating an instance:

  1. Get the list of fields.
    To get the list of fields, get the Fields metadata. The required fields have input validation "Not Null".
    If a field is linked to a list, get the possible values from list-items.
    Do not use the field list returned by retrieving a single instance. The data returned for an instance may contain calculated fields that cannot be POSTed or PUT.
  2. Create a string that has data for all the required fields and any additional fields you want to initialize. The JSON input must be in the same format returned by a GET operation on members of the collection.
  3. POST the data to the collection.
  4. On success, the HTTP return value is 201. The returned string is the complete data of the new instance. The new instance has the default values for any field not specified in the POST input.
    The Location header contains the URI of the created instance.
       
Post a defect
*** Request ***
POST /qcbin/api/domains/DEFAULT/projects/rest_documentation/defects HTTP/1.1
Host: my-server:8081
Connection: keep-alive
Content-Length: 347
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
Accept-Language: en-US,en;q=0.8,he;q=0.6
Cookie: JSESSIONID=1234567890;
XSRF-TOKEN=1234567890;
QCSession=1234567890;
ALM_USER=1234567890;
LWSSO_COOKIE_KEY=1234567890
{
    "data": [
        {
            "type": "defect",
            "name": "Willoughby disaffected with Marianne",
            "description": "Refuses to acknowledge her.",
            "priority": "4-Very High",
            "detected-by": "steves",
            "severity": "2-Medium",
            "creation-time": "2014-11-30"
        }
    ]
}
*** Response ***
HTTP/1.1 201 Created
Date: Thu, 15 Jan 2015 08:37:23 GMT
Set-Cookie: LWSSO_COOKIE_KEY=WdhlNKVnUHXbeQGuQCSMu5Zo0rWKK6tJwOZTUKw-jNrwDh3G1G8dUPrm32PHWxNEF96PnVF42mtlkfN66RAxteImU63J0WmyegrMTrZpsWVm7JMl8SUnaYu76tVOH1gfaZWo3c2HjqRnErl-PrrgRd3JI9iel1oYGIp_9Chb8nHnpFgJsHJRl-E1Cz3LfuSTYgVVnso7eXsM2DMvgQAkreEsB3PMQRFvKmYG10YCPj_lSSsuAIKvr7A8ZdzleWCfpi_8WeNOd0AW9CUG-4__gneoEx5SCxvw5v88d2i6N4R7EXJwz3ZBJ7Tbe0GajSBP;Path=/;HTTPOnly
Content-Type: application/json
Content-Length: 955
Server: Jetty(9.1.3.v20140225)
Location: http://my-server:8081/qcbin/api/domains/DEFAULT/projects/rest_documentation/defects/6
{
    "type": "defect",
    "has-change": null,
    "planned-closing-ver": null,
    "test-reference": null,
    "subject": null,
    "reproducible": null,
    "request-id": null,
    "request-server": null,
    "id": 6,
    "ver-stamp": 1,
    "has-others-linkage": "N",
    "description": "<html><body>\nRefuses to acknowledge her.\n</body></html>",
    "priority": "4-Very High",
    "name": "Willoughby disaffected with Marianne",
    "has-linkage": "N",
    "run-reference": null,
    "cycle-reference": null,
    "dev-comments": null,
    "creation-time": "2014-11-30",
    "to-mail": null,
    "request-note": null,
    "closing-version": null,
    "cycle-id": null,
    "detection-version": null,
    "last-modified": "2015-01-15 11:03:44",
    "status": null,
    "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": "steves",
    "environment": null,
    "step-reference": null,
    "owner": null,
    "target-rcyc": null,
    "actual-fix-time": null,
    "request-type": null
}