Schema import

When you want to use an existing schema to generate the test data, then by using the POST method you can import a schema into the HCL® OneTest Data project. The schema that you want to import must be either in the JSON or XSD format.

Prerequisites

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

REST API request

To import a schema, you must use the request with the following attributes:

Request attributes Request parameters
HTTP method POST
Endpoint https://{OneTest_Server}/onetest-data/rest/v1/otd/projects/{project_id}/schemas/import
Authorization Yes
Form data
Property name Data type Description Required
name String Name of the schema Yes
description String Sample description No
type String Schema type No
path String Schema path No
tags Array Schema tags No
file File Schema file Yes
Note: The name and file properties are the mandatory in the request.

Response code

You can view the following response after you run the request:

HTTP response code Response example
200
{ 
  "code":200, 
  "Message":"Schema imported successfully", 
  "id":"83", 
  "href":"http://{my-ots}-hip-server:8080/tx-server/rest/v1/tx/tasks/83", 
  "percent_complete":0, 
  "SchemaName":"Hippa", 
  "status":"new" 
}  

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
 { 
  "_id":null, 
  "name":null, 
  "message":" A schema name already exists in project 1150.", 
  "code":400 
}  
500
{ 
  "_id":null, 
  "name":null, 
  "message":"", 
  "code":500 
} 
 

Example of the cURL command

You can also use the following cURL command to import a schema from your computer to the HCL® OneTest Data project:

curl -X POST 'https://otd-fvt1.nonprod.hclpnp.com/onetest-data/rest/v1/otd/projects/1150/schemas/import' \ 
--header 'Authorization: Bearer xxxxx' \ 
--header 'Content-Type: multipart/form-data' \ 
--form 'name=Swift Schema' \ 
--form 'file=@swift_iso7775_2019.json'