简体   繁体   中英

Salesforce REST API: query with date in where clause

I am using salesforce REST API to retrieve all the accounts. Something like this:

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

I need to retrieve the delta records once a day. So I am planning to use 'lastmodifiedDate'. Retrieve any record where the lastmodifiedDate is greater than my last pull. But I am getting an error

.../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"
} ]

when I try this 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 '>'

How can I get results with date in the where clause?

Thanks

I had to encode the '+' in the time as well. So the final query is

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM