Skip to content

Delete rows

DataTablesDeleteRows collection allows deleting existing rows using HTTP POST method. It is possible to delete rows based on criteria in filters.

Important!
Remeber to carefully check filter setting because incorrect use of filters can end up with removing too many records.

Request data format

Request URL parameters:

ParameterTypeNotes
ApiKeystringYour API key, required for authentication. Required.
TableNamestringName of Data Table. Required.
FilterscomplexCollection of Filter elements. This is an equivalent of SQL “WHERE” directive. Required.

Filters element children:

ParameterTypeNotes
NamestringColumn name. Required.
OperatorstringOperator. Required. Can be one of the following:
EQ (equals, “=”). Default value
GT (greater than, “>”)
LT (lower than, “<“)
GE (greater or equal, “>=”)
LE (lower or equal, “<=”)
ValuestringValue. Required. See below for supported types.

Column element Value supported types:

  • Text, e.g. foobar
  • Number, e.g. 123
  • Double, e.g. 12.3
  • Date, YYYY-MM-DD format, e.g. 2015-11-26
  • Datetime, YYYY-MM-DD hh:mm:ss format, e.g. 2015-11-26 12:00:00
  • Boolean, e.g. true, false, 1, 0

Response

Response Count element:

Element/attributeTypeNotes
CountintNumber of records deleted.

Examples

Request (deleting a records from table based on filters):

POST https://api.esv2.com/v2/Api/DataTablesDeleteRows/ 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>MyTestApiKey</ApiKey>
   <TableName>MyTable</TableName>
   <Filters>
       <Filter>
            <Column>
                <Name>id</Name>
                <Operator>LE</Operator>
                <Value>8</Value>
             </Column>
        </Filter>
        <Filter>
            <Column>
                 <Name>bool2</Name>
                 <Operator>EQ</Operator>
                 <Value>1</Value>
             </Column>
        </Filter>
   </Filters>
</ApiRequest>

Equivalent SQL query:

DELETE FROM MyTable WHERE id <= 8 AND bool2 = 1

OK response:

HTTP/1.1 200 OK
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

<ApiResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Count>1</Count>
</ApiResponse>

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>No row matching specified criteria was found.</Message>
   </ErrorMessage>
</ApiResponse>
On this page
To top