Przejdź do treści

Add row

DataTablesAddRow collection allows adding new rows to Data Tables using HTTP POST method. It is possible to add a single row or multiple rows with one request.

Request data format

ParameterTypeNotes
ApiKeystringYour API key, required for authentication. Required.
TableNamestringName of Data Table. Required.
DatacomplexObject containing row data. Used to add a single row to Data Table. Required, unless you are using MultiData to add multiple rows instead.
MultiDatacomplexCollection of Row elements. Used to add multiple rows to Data Table. Required, unless you are using Data to add a single row instead. This option is deprecated – please use Add multiple rows method.

Data element children:

ParameterTypeNotes
ColumnscomplexCollection of Column elements.

Column element children:

ParameterTypeNotes
NamestringColumn name. Required.
ValuestringField value. Required.

To add multiple rows, use MultiData element instead of Data element (this option is deprecated – please use Add multiple rows method):

Element/attributeTypeNotes
MultiDatacomplexCollection of Row elements that have the same structure as Data element in request adding a single row.

Examples

Request (adding single row):

POST https://api.esv2.com/v2/Api/DataTablesAddRow/ HTTP/1.1
Accept-Encoding: gzip,deflate
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 269

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <TableName>Table1</TableName>
  <Data>
    <Columns>
      <Column>
        <Name>Column1</Name>
        <Value>Value1</Value>
      </Column>
      <Column>
        <Name>Column2</Name>
        <Value>2</Value>
      </Column>
      <Column>
        <Name>Column3</Name>
        <Value>2013-01-01 01:00:00 PM</Value>
      </Column>
      <Column>
        <Name>Column4</Name>
        <Value>4.66</Value>
      </Column>
      <Column>
        <Name>Column5</Name>
        <Value>True</Value>
      </Column>
    </Columns>
  </Data>
</ApiRequest>

Request (adding multiple rows) this option is deprecated – please use Add multiple rows method:

POST https://api.esv2.com/v2/Api/DataTablesAddRow/ HTTP/1.1
Accept-Encoding: gzip,deflate
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 269

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <TableName>Table1</TableName>
  <MultiData>
    <Row>
      <Columns>
        <Column>
          <Name>Column1</Name>
          <Value>Value1</Value>
        </Column>
        <Column>
          <Name>Column2</Name>
          <Value>2</Value>
        </Column>
        <Column>
          <Name>Column3</Name>
          <Value>2013-01-01 01:00:00 PM</Value>
        </Column>
        <Column>
          <Name>Column4</Name>
          <Value>4.66</Value>
        </Column>
        <Column>
          <Name>Column5</Name>
          <Value>True</Value>
        </Column>
      </Columns>
    </Row>
    <Row>
      <Columns>
        <Column>
          <Name>Column1</Name>
          <Value>Value2</Value>
        </Column>
        <Column>
          <Name>Column2</Name>
          <Value>3</Value>
        </Column>
        <Column>
          <Name>Column3</Name>
          <Value>2013-01-01 01:00:00 PM</Value>
        </Column>
        <Column>
          <Name>Column4</Name>
          <Value>4.66</Value>
        </Column>
        <Column>
          <Name>Column5</Name>
          <Value>True</Value>
        </Column>
      </Columns>
    </Row>
  </MultiData>
</ApiRequest>

OK response:

HTTP/1.1 201 Created
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 1.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Wed, 28 Oct 2009 15:35:17 GMT
Content-Length: 0

Error response:

HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 1.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Wed, 28 Oct 2009 11:32:07 GMT
Content-Length: 239

<ApiResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <ErrorMessage>
      <Code>400</Code>
      <Message>Row with specified criteria already exists</Message>
   </ErrorMessage>
</ApiResponse>

Request (inserting NULL value into column):

POST https://api.esv2.com/v2/Api/DataTablesAddRow/ HTTP/1.1
Accept-Encoding: gzip,deflate
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 187

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <TableName>Table1</TableName>
  <Data>
    <Columns>
      <Column>
        <Name>NotNullColumn</Name>
        <Value>some value</Value>
      </Column>
      <Column>
        <Name>NullableColumn</Name>
        <Value xsi:nil="true"/>
      </Column>
    </Columns>
  </Data>
</ApiRequest>