条目批量删除

Delete rows 条目批量删除

采用 HTTP POST 方式可以删除Data table中的现有条目.
它只允许通过一个请求删除一个条目.

请求数据格式

请求URL参数:
参数 类型 描述
ApiKey string 你的 API key, 用于身份验证. 必填
TableName string 数据表格名称. 必填
Filters complex 区分各个被删除条目的标识. 各个列元素值的集合 (包含多个column元素). 必填


Filters子元素:

参数 类型 描述
Name string 列名称. 必填.
Operator string 操作符. 必填. 可为下列中一个:

    • EQ (等于, “=”). 默认值
    • GT (大于, “>”)
    • LT (小于 “<“)
    • GE (大于或等于, “>=”)
    • LE (小于或等于, “<=”)
Value string 值. 必填. 见下面有效类型.

有效值类型:

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

应答

应答计数元素:
元素/属性 类型 描述
Count int 已删除的记录数量.

示例:

请求 (根据过滤条件从列表中一个删除):
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>
对应的SQL操作:
DELETE FROM MyTable WHERE id <= 8 AND bool2 = 1 
OK应答:
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>
错误应答:
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>