You need to sign in to do that
Don't have an account?

Need a Bulk API Example to start
Hi,
Can any one explain Bulk api with a small sample code.
I know bulk api is used for processing large amounts of data and is being used with apex data loader but what if some wants to impliment bulk api without the apex dataloader.
Please help with an example.
Thanks.
Hi Urvasi,
1) Bulk api always returns csv files as a result.
2) function getBulkConnection creates connection with salesforce, you need to provide your
user name and password (password + token).
3) createJob function creates job which will execute bulk operation.
4) createBatchesFromCSVFile function creates result csv file and saves to path given in "csvFileName" parameter.
Below is the example which I used in my requirement.
//This is first function which I calls when I need to execute my query using bulk api.
//Below function I am using to create connection with salesforce
//Below function creates jobs
//Below function executes query to fetch data.
//I am using following function when i need to do insert/update operation to salesforce from csv file
I hope this will be helpful to you.
All Answers
What do you want to do with the BULK API? Means what is the actual requirement here?
Thanks
http://www.salesforce.com/us/developer/docs/api_asynch/Content/asynch_api_code_walkthrough.htm
It was useful to me for developing bulk API code in java.
Thanks souvik for the reply
Currently i am using soap api to transfer records,but its hiting many of the governor limits like
Maximum size of callout request or response (HTTP request or Web services call): 3 MB
Total no of callouts : 10
So i am looking for a workaround for it,trying to use soap api with bulk api so that i can transfer data in bulk without hitting the governor limits.
Can u please provide me with some start example of learning bulk api or can you give me some practical implimetation of bulk api.
Thanks a lot :)
Thanks dapanchal.
But can u please tell me what is the java code doing,the link you have provided me with?
Hi Urvasi,
1) Bulk api always returns csv files as a result.
2) function getBulkConnection creates connection with salesforce, you need to provide your
user name and password (password + token).
3) createJob function creates job which will execute bulk operation.
4) createBatchesFromCSVFile function creates result csv file and saves to path given in "csvFileName" parameter.
Below is the example which I used in my requirement.
//This is first function which I calls when I need to execute my query using bulk api.
//Below function I am using to create connection with salesforce
//Below function creates jobs
//Below function executes query to fetch data.
//I am using following function when i need to do insert/update operation to salesforce from csv file
I hope this will be helpful to you.
Hey thanks dapanchal for the code.But i had few doubts regarding the code:
1.How does the above code utilize the concept of Bulk Api of Salesforce.
2.How will you call these methods in Salesforce.I mean how will it be consumed in Salesforce.(using a webservice or wsdl or wat)
3.When i tried creating a proj in eclipse,i found that this code is incomplete,it has many classes and many methods within it.If you could please provide an entire skelton of the code including its classes and interfaces it would very grateful,as i am new to java,so its becoming difficult to understand.
Thanks a lot Once again.
I got answers to the qs i had asked above.But my doubt here is my proxy settings are not allowing me to login to salesforce using the following url
Failed to send request to https://login.salesforce.com/services/Soap/u/26.0
which is specified in the code.Please help me regarding this.Would be really grateful of you.
Thanks a lot.
Go to Setup-> Develop -> Api -> click any of link (i.e. partner wsdl) -> search text (i.e. login.salesforce.com....) u will find url with version. try to use that url. I am not sure but that might be work.
Ya i wll try that.
But can u please give me the jar files of the source code u have jus uploaded.
Please share them,as ur code is very different from the bulk api developer guide client application one.
Thanks a lot.:)
Please share the jar files.
https://drive.google.com/folderview?id=0B6cPMtpRoi9FUVNUR09UNjRoS2c&usp=sharing
partner.jar and wsc-22.jar file are for salesforce API and opencsv.jar is not related to salesforce but i have used it for creating and reading csv files.
Hey thanks a lot for the jar files.
But one more issue
I am getting error here:
CommonPropertyManager cpm = PropertyManagerFactory.getCommonPropertyManager();
Can u tell me y is it so?
Even after uploading all the jars.
Thanks a lot :) :)
don't use that, it is our internal custom property. it just retrieves directory path. so you don't worry about that. use your code to get directory. its not from jar files.
How can we get the Bulk Query results in a csv file, from withnin the java code ?
My requirement is to write a java batch which will do bulk query followed by bulk delete those records.
I am assuming for bulk delete, you need to have a csv file. Please correct me if i am wrong.
-Sid
its really helpful for newbie
we have requirement to send the BULK messages to SFDC through Java API.
Java code to connect with SFDC:
static final String USERNAME = "userId";
static final String PASSWORD = "password+securitykey";
static final String authEndpoint="https://test.salesforce.com/services/Soap/c/37.0/0DF630000008OVd";
static EnterpriseConnection connection;
public static void main(String[] args) {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(USERNAME);
config.setPassword(PASSWORD);
config.setProxy("proxy-url", 8080);
config.setAuthEndpoint(authEndpoint);
try {
connection = Connector.newConnection(config);
}
but while establishing the connction to SFDC getting below error:
com.sforce.ws.ConnectionException: Failed to send request to https://test.salesforce.com/services/Soap/c/37.0/0DF630000008OVd
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:120)
at com.sforce.soap.enterprise.EnterpriseConnection.login(EnterpriseConnection.java:1)
at com.sforce.soap.enterprise.EnterpriseConnection.<init>(EnterpriseConnection.java:1)
at com.sforce.soap.enterprise.Connector.newConnection(Connector.java:1)
at SFDCBulkAPI.main(SFDCBulkAPI.java:26)
Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Service Unavailable"
Note : 1. We are able to get the session id when we excute it through SAP PI with the same userid,password and proxy url.
2. USERNAME , PASSWORD and in "proxy-url" we supplied the valid value in the above java code.
Could you please help me here whey we are unable to send the request through the above Java code.
Thanks in advance,
Vilas
I am using below code
final ConnectorConfig config = new ConnectorConfig();
config.setRestEndpoint(restEndpoint);
config.setSessionId(accessToken);
final BulkConnection connection = new BulkConnection(config);
JobInfo job = new JobInfo();
job.setObject(sobjectType);
job.setOperation(OperationEnum.insert);
job.setContentType(ContentType.CSV);
job = connection.createJob(job);
[AsyncApiException exceptionCode='ClientInputError'
exceptionMessage='Failed to parse exception '
]
at com.sforce.async.BulkConnection.parseAndThrowException(BulkConnection.java:201)
at com.sforce.async.BulkConnection.createOrUpdateJob(BulkConnection.java:166)
at com.sforce.async.BulkConnection.createOrUpdateJob(BulkConnection.java:134)
at com.sforce.async.BulkConnection.createJob(BulkConnection.java:124)
at com.intuit.platform.crms.CrmsDataPlatformApplicationTests.createJob(CrmsDataPlatformApplicationTests.java:117)
at com.intuit.platform.crms.CrmsDataPlatformApplicationTests.getConnection(CrmsDataPlatformApplicationTests.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)..