Schema creation

When you want to generate test data by using HCL® OneTest Data, you must create a schema. You must use the POST method to create a schema from any external application.

Prerequisites

You must have the following information before you create a schema:

REST API request

To create a schema, you must use the request with the following attributes:
Note: The schema you create is only the schema definition without any type definitions. The Dictionary and Structure are blank and they get updated only after you add the type definitions.
Request attributes Request parameters
HTTP method POST
Endpoint https://{OneTest_Server}/onetest-data/rest/v1/otd/projects/{project_id}/schemas
Authorization Yes
Request body
{
"name":<Schema_Name>, 
"description":<Schema_Description> 
}

Response code

You can view the following response after you run the request:
HTTP response code Response example
200
{ 
  "_id":"5efb2c6f0f11a4009dfdbe6c", 
  "name":"otdschema11", 
  "message":"Schema created successfully", 
 “code”:200 
} 

Error codes

The following table lists the error codes that can generate on the failure of the request:
HTTP error codes Response examples
401 (Invalid Token)
{ 
  "timestamp":"2020-07-01T05:22:29.233Z", 
  "code":401, 
  "messages":["Invalid token."] 
} 
401 (Session Expired)
{ 
  "timestamp":"2020-07-01T05:22:29.233Z", 
  "code":401, 
  "messages":["Session expired."] 
} 
400
 Duplicate schema Name 
{ 
  "timestamp":"2020-07-19T13:16:00.450Z", 
  "code":400, 
  "messages":[" A schema with the name otd_schema and path \"\" already exists in project otd_project." ]
}
Blank or null value for Schema Name 
{ 
  "timestamp":"2020-07-19T13:16:00.450Z", 
  "code":400, 
  "messages":["Schema Name must be specified."] 
} 
500
{ 
  "timestamp":"2020-07-19T13:16:00.450Z", 
  "code":500, 
  "messages":["Create schema failed with following exception."] 
}
 

Example of the cURL command

You can also use the following cURL command to create a schema for your HCL® OneTest Data project:

curl -X POST 'https://otd-fvt2.nonprod.hclpnp.com/onetest-data/rest/v1/otd/projects/1150/schemas' \ 
--header 'Accept: application/json;charset=utf-8' \ 
--header 'Content-Type: application/json;charset=utf-8' \ 
--header 'Authorization: Bearer xxxxx' \ 
--data-raw '{ 
    "name": "ExampleSchema1", 
    "description": "Schema for creating employee details" 
}'