Product Documentation

FairCom REST API Reference

Previous Topic

Next Topic

Record

Methods are provided for creating, deleting, loading, updating, and retrieving information about records:

For information on locating records via methods other than numeric ID, see the Find section.

Note: This API expects and returns dates/times in the format of MDCY and HJMST. I.e., MM/DD/CCYY h|hh:mm:ss.ttt (24 h) (ttt are milliseconds). Hours can be either one or two digits. (See c-treeDB Date Formats and c-treeDB Time Formats for details and alternative formats.)

Previous Topic

Next Topic

Create Record - POST

Add a new record to the specified table in the specified database.

Type: POST

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

Parameters:

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

Body:

A JSON string containing one object or an array of objects to create multiple records. Each object will consist of field names and associated values.

{
"field1": "This is the field value",
"field2": 39,
"field3": "Another field value"
}

OR create multiple records at a time by using an array of objects:

[
{
"field1": "String value",
"field2": 39
},
{
"field1": "Other string value",
"field2": 40
}
]

Example:

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

[
{
"part_name" : "Wide Angle lens",
"part_description" : "28mm equivalent, fixed focus",
"part_number" : 1395
},
{
"part_name" : "Image Sensor",
"part_description" : "10MP CCD with controller",
"part_number" : 1394
}
]

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 IDs of the record(s) created. Example:

{
"_ids": [
1,
2
    ]
}

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

Previous Topic

Next Topic

Delete Record by ID - DELETE

Delete a record by specified ID from the specified table and database.

Type: DELETE

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

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name
  • id (required) - Record ID

Example:

DELETE https://localhost:8443/ctree/api/v1/record/ctreeSQL/part/1234

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. Data returned in the body depends on the request.
  • 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 Record by ID - GET

Get a single record specified by ID from the specified table and database. See the Find section for other ways to find records.

Type: GET

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

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name
  • id (required) - Record ID

Example:

GET https://localhost:8443/ctree/api/v1/record/ctreeSQL/part/2

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 specified record. Example:

{
"part_number": 1395,
"part_name": "Wide Angle lens",
"part_description": "28mm equivalent, fixed focus"
}

  • 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

Update Record by ID - PUT

Update an entire existing record specified by ID from the specified table and database. All fields will be changed. Included fields will be set to the supplied values, fields not included in the body will be set to null.

Type: PUT

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

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name
  • id (required) - Record ID

Body:

A JSON string consisting of field names and associated values:

{
"field1": "This is the field value",
"field2": 39,
"field3": "Another field value"
}

Example:

PUT https://localhost:8443/ctree/api/v1/record/ctreeSQL/part/1

{
"part_name" : "Wide Angle lens",
"part_description" : "17mm equivalent, manual focus",
"part_number" : 1395
}

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

Update Selected Fields - PATCH

Update a record specified by ID within the specified table and database. Only included fields will be changed. Fields not included in the body will be left as-is.

Type: PATCH

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

Parameters:

  • db (required) - Database Name
  • table (required) - Table Name
  • id (required) - Record ID

Body:

JSON list of property/value pairs of fields in the record or an array of records:

{
field1: "New value"
}

Example:

PATCH https://localhost:8443/ctree/api/v1/record/ctreeSQL/part/1

{

"part_description" : "17mm equivalent, auto focus"

}

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.

TOCIndex