Product Documentation

FairCom REST API Reference

Previous Topic

Next Topic

Tables

Methods are provided for creating, deleting, and getting information about tables:

Previous Topic

Next Topic

Create Table - POST

This command creates a table. You must supply the name of the database in which the table will be created and a name for the table. The body of the command contains the field definitions as a JSON list.

Type: Post

URL: /ctree/api/v1/table/{db}/{table}

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name

Body:

A JSON string containing an array of objects specifying the table fields. Each field object consists of the following properties:

The name property is a required string containing the field name.

The type property is a required string containing the data type of the field. Possible values are: BIT, TINYINT, SMALLINT, INTEGER, BIGINT, MONEY, DATE, TIME, REAL, DOUBLE, TIMESTAMP, BINARY, CHAR, NUMBER, VARBINARY, LVARBNARY, VARCHAR, LVARCHAR, NCHAR, NVARCHAR.

The length property is an integer that is required for field types CHAR, NCHAR, and BINARY. The property indicates the number of bytes used to store the field. It is optional for VARCHAR, NVARCHAR, VARBINARY and indicates the intended length.

The scale property is an integer that is only required for the NUMBER field type and specifies the number of digits to the right of the decimal point.

The precision property is an integer that is only required for the NUMBER field type and specifies the total number of digits available to represent a number including digits on the left and right of the decimal point.

Example:

POST https://localhost:8443/ctree/api/v1/table/ctreeSQL/part

{

"fields" : [

{

"name" : "part_number",

"type" : "INTEGER",

"length" : 4

},

{

"name" : "part_name",

"type" : "CHAR",

"length" : 30

},

{

"name" : "part_description",

"type" : "VARCHAR",

"length" : "300"

}

]

}

When you want to connect using a secure connection over TLS, use https:// and port 8443. Without TLS use http:// and port 8080.

Responses:

  • 200 - OK.
  • 400 - URI is in the wrong format. Body contains details about the error.
  • 401 - Unauthorized.
  • 500 - Internal error.

Previous Topic

Next Topic

Delete Table - DELETE

This command deletes the specified table from the specified database.

Type: DELETE

URL: /ctree/api/v1/table/{db}/{table}

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name

Example:

DELETE https://localhost:8443/ctree/api/v1/table/ctreeSQL/part

When you want to connect using a secure connection over TLS, use https:// and port 8443. Without TLS use http:// and port 8080.

Responses:

  • 200 - OK.
  • 400 - URI is in the wrong format. Body contains details about the error.
  • 401 - Unauthorized.
  • 404 - Request cannot be satisfied because of missing resource. Body contains details about the error.
  • 500 - Internal error.

Previous Topic

Next Topic

Get Table Definition - GET

This command returns the specified table definition as a JSON string.

Type: GET

URL: /ctree/api/v1/table/{db}/{table}

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name

Example:

GET https://localhost:8443/ctree/api/v1/table/ctreeSQL

When you want to connect using a secure connection over TLS, use https:// and port 8443. Without TLS use http:// and port 8080.

Responses:

  • 200 - OK. Returns the definition of the table. Example:

{
"fields": [
{
"name": "part_number",
"type": "INTEGER"
},
{
"name": "part_name",
"type": "CHAR",
"length": 30
},
{
"name": "part_description",
"type": "VARCHAR",
"length": 300
}
]
}

  • 400 - URI is in the wrong format. Body contains details about the error.
  • 401 - Unauthorized.
  • 500 - Internal error.

Previous Topic

Next Topic

Get a List of Tables in the Database - GET

Retrieve a list of the tables in the specified database.

Type: GET

URL: /ctree/api/v1/table/{db}

Parameters:

  • db (required) - Database Name

Example:

GET https://my-ctree-server:8443/ctree/api/v1/table/ctreeSQL

When you want to connect using a secure connection over TLS, use https:// and port 8443. Without TLS use http:// and port 8080.

Responses:

  • 200 - OK. Returns a list of tables. Example:

{

"_tables": [

"part"

]

}

  • 400 - URI is in the wrong format. Body contains details about the error.
  • 401 - Unauthorized.
  • 500 - Internal error.

TOCIndex