- 21 Nov 2022
- 2 Minutes to read
-
Print
-
DarkLight
ADD Endpoint (POST)
- Updated on 21 Nov 2022
- 2 Minutes to read
-
Print
-
DarkLight
ADD Endpoint (POST)
Initial Preparation
The Endpoint is accessed through the url: {{baseURL}}/CSSAPI/V2/{{entityName}} /Add
- baseURL – your company’s ContractInsight URL
- entityName – name of the database tables
The HTTP request type is POST. Content type for this request is set to application/json.
Introduction
Add Endpoint allows you to create records in Contract Insight database. Things to keep in mind when making calls to Add Endpoint:
- Accepts only one insert at a time. No bulk insert is supported by REST API.
- Fields that cannot be inserted include fields of type GUID (uniqueidentifier), password field, out-of-the-box date fields such as DateEntered, EntryDate, DateCreated, and CreatedDate.
- Inserting duplicate records is allowed with some tables (tblCustomers for instance). The records will be assigned unique identifiers. Other field values will be identical.
- Values that are required and have “HasDefaultValue” set to “false” must be provided. Values that are required and have “HasDefaultValue” set to “true” may be skipped.
Request format
The following format must be used in the request body when making calls to Add Endpoint:
Request Body (partial) |
|
Response
- Successful response has following fields:
- GeneratedId – inserted record Id (number)
- Message – contains text “Success”
- Failed response will contain the following fields:
- LogId – represents a GUID string
- Message – Error message
- Exception – the exception object.
Example of a successful response:
| Example of a failed response:
|
More on Failed Responses
When supplying non-existing column name to the REST API, a similar to the above error will be returned. In the below snapshot, we attempted to insert some value to a column “Vendor Name” (with a space) in tblCustomers table. Such column doesn’t exist in the table and we get the error back:
Invalid data type supplied for the column value will produce an exception. If we attempt to insert a string value in a column that accepts an integer value, exception returned will be similar to the one below:
Please note when a column is of type string, and we set the value to Boolean (false/true), number (int/decimal), or even an object, the request will go through without errors, and the supplied value will be converted into a string:
| When forming the request, we add an object for the “Value” key of the first Tuple. |
The resulting value in tblCustomers for the VendorName column. |