function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vj@88Vj@88 

SOQL query failing when using SOAP API

I am trying to query records using IN clause via SOAP API, but It is throwing  me the error --

'Failed to process query: MALFORMED_QUERY: SOQL statements cannot be empty or null'
Query - list contains around 550 ID's like
 SELECT id from Account where id IN ('001i000000iG2EJAA0','001i000000iGHzvAAS','001i000000iFHpbAAS','001i000000iFGYXAAW','001i000001F2hTgAAJ','001i000000iErcWAAS','00001i000000iExVNAA0','001i000000iF44RAAS','001i000000iV17RAG','001i000000iEf43AAK','001i000000iF8QQAA0','001i000000iEer3AAC')

Even the length of query is within limits (around 12k char)Can you please let me know what I am doing wrong?
Vj@88Vj@88
Thanks David, but these ID's are not real ones, I just gave an example on how the query looks. I tested with real IDs, still query is failing. Any idea why?

Vijay
SkottypSkottyp
Have you tried to limit the query to 2 accnt Ids and see if that works?
Vj@88Vj@88
Yes, I tried even that. Still getting the error. PFB query string
SELECT id from Account where id IN ('001i000000iF2EJAA0','001i000000iF3zLAAS')
SkottypSkottyp
what about if you change the filter to WHERE Id = '001i000000iF2EJAA0' does it still fail?
Vj@88Vj@88
Yes, that failed too. I am using BULK API to query the records, hope its not causing the issue here.

 
Vj@88Vj@88
PFB code

              job = new JobInfo();
                job.setObject("Account");
                
                query = "SELECT id from Account where id = \'001i000000iF2EJAA0\'";
                System.out.println(query);
                job.setOperation(OperationEnum.query);
                job.setConcurrencyMode(ConcurrencyMode.Parallel);
                job.setContentType(ContentType.CSV);
                
              
                job = bulkConnection.createJob(job);
                assert job.getId() != null;
                
                job = bulkConnection.getJobStatus(job.getId());
                BatchInfo info2 = null;
                ByteArrayInputStream bout2 = new ByteArrayInputStream(query.getBytes());
                info2 = bulkConnection.createBatchFromStream(job, bout);
                  while(true){
                    info2 = bulkConnection.getBatchInfo(job.getId(), info2.getId());
                   // System.out.println(info.getState());//30 sec
                    if((info2.getState() == BatchStateEnum.Completed) || (info2.getState() == BatchStateEnum.Failed)){
                        System.out.println("Status Done" + info.getState());//30 sec
                        break;
                    }
                }
    
                  if (info2.getState() == BatchStateEnum.Completed) {
                  //logic}   ----
 
Vj@88Vj@88
Extremely sorry for wasting your time guys!! Did a silly typo mistake.
Thanks for your help.