Create an entity

To create an entity, perform a POST on the entity collection, pass an XML or JSON string that contains at least the required fields. The examples below use the defects collection, but the procedure is the same for all entities.

  1. Get the list of fields.
    To get the list of fields for an entity, use the customization fields Collection. See the example of getting the defects fields.
    To find the list of required fields, add the query parameter ?required=true to the end of the fields URL. See the example of getting the required defect fields.
    If a field is linked to a list, the field has a List-Id attribute. Use the List-Id to get the possible values from the lists Collection.
    Do not use the field list returned by retrieving a single entity. The data returned for an entity contains calculated fields that cannot be POSTed or PUT. 
  2. Create a string that has at least the required fields. XML input must comply with the Entity Schema. JSON input must be in the same format returned by a GET operation on members of the collection.
  3. POST the data to the defects collection.
  4. On success, the HTTP return value is 201. The returned string is the complete data of the new entity. The new entity has the default values for any field not specified in the POST input.
    A Location header is returned that contains the address of the new entity resource. For example:

Example with XML

POST /qcbin/rest/domains/{domain}/projects/{project}/defects HTTP/1.1
Content-Type: application/xml
Accept: application/xml
Cookie: QCSession=xxx; XSRF-TOKEN=xxx; LWSSO_COOKIE_KEY=xxx


<Entity Type="defect">
      <Field Name="detected-by">
      <Field Name="creation-time">
      <Field Name="severity">
      <Field Name="name">
         <Value>Returned value not does not match value in database.</Value>

Example with JSON

POST /qcbin/rest/domains/{domain}/projects/{project}/defects HTTP/1.1
Content-Type: application/json
Accept: application/json
Cookie: QCSession=xxx; XSRF-TOKEN=xxx; LWSSO_COOKIE_KEY=xxx


{"Fields":[{"Name":"detected-by","values":[{"value":"henry_tilney"}]},{"Name":"creation-time","values":[{"value":"2010-03-02"}]},{"Name":"severity","values":[{"value":"2-Medium"}]},{"Name":"name","values":[{"value":"Returned value not does not match value in database.</ "}]}]}