DataService. Adding records
Glossary Item Box
General information
The Creatio DataService web service is a RESTfull service. RESTful is a quite simple information management interface that doesn't use any additional internal layers, i.e., the data doesn't need to be converted to any third-party format, such as XML. In a simple RESTful service, each record is uniquely identified by a global identifier such as URL. Each URL, in turn, has a strictly specified format. However, this service is not always convenient for transferring large amounts of data.
With the use of the DataService, the data can be automatically configured in various data formats such as XML, JSON, HTML, CSV, and JSV. The data structure is determined by data contracts. A complete list of data contracts used by the DataService, can be found in the "DataService" article.
InsertQuery data contract
The InsertQuery data contract is used to add records to sections. The data is transferred to the DataService via HTTP by using the POST request with the following URL:
// URL format of the POST query to add data to DataService. http(s)://[Creatio application address]/[Configuration number]/dataservice/[Data fromat]/reply/InsertQuery // URL example for the POST query to add data to DataService. http(s)://example.creatio.com/0/dataservice/json/reply/InsertQuery
The InsertQuery data contract has a hierarchical structure with multiple nesting levels. In the Creatio application server part, the InsertQuery data contract is represented by the InsertQuery class of the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel.dll class library. However, for simplicity, the hierarchical structure of the InsertQuery data contract is conveniently presented as a JSON format object:
{ "RootSchemaName":"[Root object schema name]", "OperationType":[Record operation type], "ColumnValues":{ "Items":{ "Added column name":{ "ExpressionType":[Expression type], "Parameter":{ "DataValueType":[Data type], "Value":"[Column value]" } }... } } }
The basic properties of the InsertQuery class and their possible values are presented in table 1.
Table 1. InsertQuery class properties.
Property | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RootSchemaName | A string containing the name of the root object schema of the added record. | ||||||||||
OperationType |
Operation type is set by the QueryOperationType namespace Terrasoft.Nui.ServiceModel.DataContract namespace enumeration value. For the InsertQuery theQueryOperationType.Insert value is set. QueryOperationType enumeration values:
|
||||||||||
ColumnValues | Contains a collection of column values of the added record. Its ColumnValues type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. |
The ColumnValues class has a single Items property that is defined as a collection of the Dictionary<string, ColumnExpression> keys and values. The key is a string with the added column title, and the value is the object with the ColumnExpression type defined in theTerrasoft.Nui.ServiceModel.DataContract namespace. The basic properties of the ColumnExpression class used when adding records, are given in table 2.
Table 2. ColumnExpression class main properties
Property | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ExpressionType |
The expression type that defines the value that will be contained in the added column. Set by the EntitySchemaQueryExpressionType enumeration of the Terrasoft.Core.Entities namespace defined in the Terrasoft.Core class library. For the InsertQuery the EntitySchemaQueryExpressionType.Parameter value is set. EntitySchemaQueryExpressionType enumeration type:
|
||||||||||
Parameter |
Defines the value that will be contained in the added column. Its Parameter type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. |
The Parameter class has multiple properties, two of which are used to add records (table 3).
Table 3 Parameter class main properties
Property | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DataValueType |
The data value type that defines the value that will be contained in the added column. Set by the DataValueType enumeration value of theTerrasoft.Nui.ServiceModel.DataContract namespace. DataValueType enumeration type:
|
||||||||||||||||||||||||||||||||
Value |
The object that contains the added column value. |