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
chris_visokiochris_visokio 

Bulk API bug

Hi,

 

We use the Bulk API to query data from Salesforce. We have encountered a problem. If we execute the following code:

 

// Login
SforceServiceLocator locator = new SforceServiceLocator();
SoapBindingStub binding = (SoapBindingStub) locator.getSoap();
LoginResult result = binding.login(USERNAME, PASSWORD+SECURITY_TOKEN);
binding._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, result.getServerUrl());
binding.setHeader(locator.getServiceName().getNamespaceURI(), "SessionHeader", 
new SessionHeader(result.getSessionId()));

// Create bulk connection
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(result.getSessionId());
String serverUrl = result.getServerUrl();
String apiVersion = "22.0";
String restEndpoint = serverUrl.substring(0, serverUrl.indexOf("Soap/")) + "async/" + apiVersion;
config.setRestEndpoint(restEndpoint);
config.setCompression(true);
config.setTraceMessage(false);
BulkConnection connection = new BulkConnection(config);

// Create new job
System.out.println("Creating job");
JobInfo job = new JobInfo();
job.setObject("Campaign");
job.setOperation(OperationEnum.query);
job.setContentType(ContentType.CSV);
job.setConcurrencyMode(ConcurrencyMode.Serial);
job = connection.createJob(job);

We get the following error:
Creating job
[AsyncApiException  exceptionCode='Unknown'
 exceptionMessage='Unknown exception in Async API. Please contact support with ID: 858593402-23999 (-862000079)'
]
at com.sforce.async.BulkConnection.parseAndThrowException(BulkConnection.java:108)
at com.sforce.async.BulkConnection.createOrUpdateJob(BulkConnection.java:92)
at com.sforce.async.BulkConnection.createJob(BulkConnection.java:72)
at salesforce.SalesforceBulkApiTest.main(SalesforceBulkApiTest.java:68)

This seems to be related to the object selection. For example if we change it to:
job.setObject("Contact")
We do not get this error. We get similar errors for other tables. If its the case that these tables cannot be queried, can we determine this before we execute the query?
Thanks!
Chris
Pat PattersonPat Patterson

Hi Chris,

 

Very similar code works for me - I can't reproduce your error at all.

 

I copied your code and changed the login portion a little to match the wsc-22.jar I'm using (from http://code.google.com/p/sfdc-wsc/downloads/detail?name=wsc-22.jar):

 

        // Login
        String username = System.getenv("USERNAME");
        String password = System.getenv("PASSWORD");
        String sectoken = System.getenv("SECURITY_TOKEN");
        
        if (sectoken != null) {
            password += sectoken;
        }

        ConnectorConfig config = new ConnectorConfig();
        config.setUsername(username);
        config.setPassword(password);

        EnterpriseConnection connection;

        connection = Connector.newConnection(config);
        
        // Create bulk connection           
        ConnectorConfig bulkConfig = new ConnectorConfig();
        bulkConfig.setSessionId(connection.getSessionHeader().getSessionId());

        // The endpoint for the Bulk API service is the same as for the normal
        // SOAP uri until the /Soap/ part. From here it's '/async/versionNumber'
        String soapEndpoint = config.getServiceEndpoint();
        String apiVersion = "22.0";
        String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/"))
            + "async/" + apiVersion;
        bulkConfig.setRestEndpoint(restEndpoint);
        
        bulkConfig.setCompression(true);
        bulkConfig.setTraceMessage(false);          
        BulkConnection bulkConnection = new BulkConnection(bulkConfig);

        // Create new job
        System.out.println("Creating job");
        JobInfo job = new JobInfo();
        job.setObject("Campaign");
        job.setOperation(OperationEnum.query);
        job.setContentType(ContentType.CSV);
        job.setConcurrencyMode(ConcurrencyMode.Serial);
        job = bulkConnection.createJob(job);
        System.out.println(job);

This runs without error for me:

 

Creating job
[JobInfo  id='75050000000SEoBAAW'
 operation='query'
 object='Campaign'
 createdById='00550000001fg5OAAQ'
 createdDate='java.util.GregorianCalendar[time=1334771460000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2012,MONTH=3,WEEK_OF_YEAR=16,WEEK_OF_MONTH=3,DAY_OF_MONTH=18,DAY_OF_YEAR=109,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=51,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]'
 systemModstamp='java.util.GregorianCalendar[time=1334771460000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2012,MONTH=3,WEEK_OF_YEAR=16,WEEK_OF_MONTH=3,DAY_OF_MONTH=18,DAY_OF_YEAR=109,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=51,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]'
 state='Open'
 externalIdFieldName='null'
 concurrencyMode='Serial'
 contentType='CSV'
 numberBatchesQueued='0'
 numberBatchesInProgress='0'
 numberBatchesCompleted='0'
 numberBatchesFailed='0'
 numberBatchesTotal='0'
 numberRecordsProcessed='0'
 numberRetries='0'
 apiVersion='22.0'
 assignmentRuleId='null'
 numberRecordsFailed='0'
 totalProcessingTime='0'
 apiActiveProcessingTime='0'
 apexProcessingTime='0'
]

 

BC_IABC_IA

Hi,

 

We are also getting this error on Account, Contact and Lead object but it is working fine on Users and Task.

 

Is is something to do with the setting on Object levels/ permission? It seems somewhere permission is missing as process is working for one object than ofcourse it should work for other objects as well.

 

I am able to fetch records for all objects using SOAP, facing problem only on Bulk API.

 

Thanks in advance!!

BC

 

chris_visokiochris_visokio

Yes we get the error on these objects too. It must be a permission setting, so is there any way to deterimine up front whether we can query these tables. These tables are being returned when we request a list of all available objects.

BC_IABC_IA

You mentioned that "These tables are being returned when we request a list of all available objects.".

 

Is there a way to get a list of all available objects via Bulk API ie using HTTP get /post?

 

Please do send me.If i can get some clue.

 

-Thanks!!

chris_visokiochris_visokio

No, as far as I'm aware you can only get a list of available objects using the Web service. The bulk API is used for executing bulk queries on a named object. To obtain a list of objects we use the following code:

 

SforceServiceLocator locator = new SforceServiceLocator();

SoapBindingStub stub =  (SoapBindingStub) locator.getSoap();

...

ArrayList<String> tableNames = new ArrayList<String>();

for (DescribeGlobalSObjectResult sObjectResult : stub.describeGlobal().getSobjects()) {
tableNames.add(sObjectResult.getName());
}

 

So if the crash described above IS a permissions problem, then this method is retruning me a list of tables i shouldn't be able to see. So is there a check I need to make beforehand before I add it to the list of tables that can be queried?

 

Pat PattersonPat Patterson

Chris,

 

I'm trying to reproduce this error to figure out why I can do a Bulk API query on Campaign, but you can't. What are your CRUD settings on Campaign in the user's profile?

 

Cheers,


Pat

BC_IABC_IA

Hi, I did checked the response from DescribeGlobal and found that the Object which is working[Task] is having more permissions than the Object [Account]. In our case Task is working and account is causing problem in case of Bulk API.

 

Though both are having permissions as queryable, retrieveable and searchable true.

 

Could you please also check and compare two different objects one which is working and other which is not working.


Pat PattersonPat Patterson

@BC_IA - What are the differences in the permissions between Task and Account? I'd like to try to reproduce this and pin it down as much as possible.

BC_IABC_IA

Sorry for the late reply Pat.

 

As  I mentioned both are having permissions as queryable, retrieveable and searchable to true and infact that is what we  require for quering/retrieving from BulkAPI.

 

I am just fetching data in both the cases, but Task is having more permissions as Creatable, insertable and etc. So my assumption is that there could be bug in there system which is checking some other persmission as well.

 

If anyone else can verify than we can reach to  the final conclusion.

chris_visokiochris_visokio

Hi,

Appologies for the delay in replying.

Ok, so I iterated through the objects using:

for (DescribeGlobalSObjectResult sObjectResult : stub.describeGlobal().getSobjects()) {

I then printed out a list of permissions for "Campaign" (which shows an error when I try and query) and "Task", which I am able to query. The permissions are as follows:

 

Campaign:
isActivateable=false
isCreateable=false
isCustom=false
isCustomSetting=false
isDeletable=false
isDeprecatedAndHidden=false
isFeedEnabled=false
isLayoutable=true
isMergeable=false
isQueryable=true
isReplicateable=true
isRetrieveable=true
isSearchable=true
isTriggerable=true
isUndeletable=false
isUpdateable=false


Task:
isActivateable=false
isCreateable=true
isCustom=false
isCustomSetting=false
isDeletable=true
isDeprecatedAndHidden=false
isFeedEnabled=false
isLayoutable=true
isMergeable=false
isQueryable=true
isReplicateable=true
isRetrieveable=true
isSearchable=true
isTriggerable=true
isUndeletable=true
isUpdateable=true

 

So in both cases isQueryable=true.

chris_visokiochris_visokio

Hi,

 

Is there any update on this?

bpovlichbpovlich

I'm also trying to figure this one out.  Any update?

Pat PattersonPat Patterson

Chris - apologies for the delay in replying. Please log a case on this, if you have not already done so.