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:
- A bearer token. See Retrieval of a bearer token
- Project details. See Retrieval of the project details
- You must have either a JSON or XSD file on your computer.
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 |
|
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'