【问题标题】:Salesforce REST API: query with date in where clauseSalesforce REST API:在 where 子句中使用日期查询
【发布时间】:2017-05-02 15:54:28
【问题描述】:

我正在使用 Salesforce REST API 来检索所有帐户。像这样的:

..."/query?q=select+name,+cust_number__c,+cust_status__c+from+account+where+cust_number__c+!=null"

我需要每天检索一次增量记录。所以我打算使用'lastmodifiedDate'。检索 lastmodifiedDate 大于我上次拉取的任何记录。但我收到一个错误

.../query?q=select+name,+CreatedDate+,+lastmodifiedDate,+cust_number__c,+cust_status__c+from+account+where+lastmodifiedDate+%3e+2017-04-03T20:12:37.000+0000;

Query was unsuccessful. Status code returned is 400
An error has occured. Http status: 400
[ {
  "message" : "\nlastmodifiedDate > 2017-04-03T20:12:37.000 0000\n                                         ^\nERROR at Row:1:Column:159\nline 1:159 no viable alternative at character ' '",
  "errorCode" : "MALFORMED_QUERY"
} ]

当我尝试这个查询时:

    .../query?q=select+name,+CreatedDate+,+lastmodifiedDate,+cust_number__c,+cust_status__c+from+account+where+lastmodifiedDate+>+2017-04-03T20:12:37.000+0000;

    Query URL: Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in query at index 190:

    Exception for '>'

如何在 where 子句中获得带有日期的结果?

谢谢

【问题讨论】:

    标签: rest salesforce


    【解决方案1】:

    当时我还必须对“+”进行编码。所以最终的查询是

     .../query?q=select+name,+CreatedDate+,+lastmodifiedDate,+cust_number__c,+cust_status__c+from+account+where+lastmodifiedDate+%3e+2017-04-03T20:12:37.000+0000
    

    【讨论】:

      猜你喜欢
      • 2014-08-24
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多