ADD Endpoint (POST)
  • 21 Nov 2022
  • 2 Minutes to read
  • Dark
    Light

ADD Endpoint (POST)

  • Dark
    Light

Article Summary

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.

Graphical user interface, application, Teams

Description automatically generated

 

Introduction

Add Endpoint allows you to create records in Contract Insight database. Things to keep in mind when making calls to Add Endpoint:

  1. Accepts only one insert at a time. No bulk insert is supported by REST API.
  2. 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.
  3. Inserting duplicate records is allowed with some tables (tblCustomers for instance). The records will be assigned unique identifiers. Other field values will be identical.
  4. 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)

  1. The request object has single key “Tuple” that corresponds to a record in SQL table.
  2. Tuple represents an array (collection) of objects. They are essentially the attributes of an entity or columns in a database table.
  3. Each object inside the collection has two keys: Name and Value. Name represents the column name. Value represents the value for that column.

 

 

Response

  1. Successful response has following fields:
    1. GeneratedId – inserted record Id (number)
    2. Message – contains text “Success”
  2. Failed response will contain the following fields:
    1. LogId – represents a GUID string
    2. Message – Error message
    3. 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.




Was this article helpful?