Перейти к содержимому

Update multiple rows

DataTablesUpdateMultipleRows allows updating existing rows using HTTP POST method. It is possible to update multiple rows in one data table in one request by specifying row unique identifier (PK, primary key) for each row.

Request data format

ApiRequest element children:

ParameterTypeNotes
ApiKeystringYour API key, required for authentication. Required.
TableNamestringName of Data Table. Required.
DatacomplexObject containing rows data. Required.

Data element children:

ParameterTypeNotes
ColumnscomplexCollection of row elements. Required.

Row element children:

ParameterTypeNotes
PrimaryKeyColumnscomplexCollection of Column elements. Contains unique identifier (PK, primary key) of the row that is supposed to be updated. This is an equivalent of SQL «WHERE» directive. Required. 
ColumnscomplexCollection of Column elements. Contains information only about columns that are supposed to be updated and their new values. This is an equivalent of SQL «SET» directive. Required. 

Column element children:

ParameterTypeNotes
ColumnstringColumn name. Required.
ValuestringField value. Required.

Examples

Request:

POST https://api.esv2.com/v2/Api/DataTablesUpdateMultipleRows/ HTTP/1.1

<ApiRequest xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ApiKey>test_api_key1</ApiKey>
  <TableName>Table1</TableName>
  <Data>
    <Row>
      <PrimaryKeyColumns>
        <Column>
          <Name>Column1</Name>
          <Value>Value1</Value>
        </Column>
      </PrimaryKeyColumns>
      <Columns>
        <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>
      <PrimaryKeyColumns>
        <Column>
          <Name>Column1</Name>
          <Value>Value2</Value>
        </Column>
        <Column>
          <Name>Column2</Name>
          <Value>3</Value>
        </Column>
      </PrimaryKeyColumns>
      <Columns>
        <Column>
          <Name>Column1</Name>
          <Value>Value5</Value>
        </Column>
        <Column>
          <Name>Column2</Name>
          <Value>5</Value>
        </Column>
        <Column>
          <Name>Column5</Name>
          <Value>True</Value>
        </Column>
      </Columns>
    </Row>
  </Data>
</ApiRequest>

OK response:

HTTP/1.1 204 No Content
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

<ApiResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <ErrorMessage>
  <Code>400</Code>
  <Messages>
   <Message for="Row 1">Row with specified criteria already exists.</Message>
   <Message for="Row 2">Request does not contain required columns.</Message>
   <Message for="Row 3">No row matching specified criteria was found.</Message>
   <Message for="Row 4">Validation error, field type:Number value:test</Message>
  </Messages>
 </ErrorMessage>
</ApiResponse>

Please note that the error response contains information about errors in specific rows (identified by the index number of a row, starting from 1). If there were rows that were not reported here as an error it means that those rows were successfully updated in data tables.

On this page
To top