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

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?
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?

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

PFB code

              job = new JobInfo();
                query = "SELECT id from Account where id = \'001i000000iF2EJAA0\'";
                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);
                    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
                  if (info2.getState() == BatchStateEnum.Completed) {
                  //logic}   ----
Extremely sorry for wasting your time guys!! Did a silly typo mistake.
Thanks for your help.