• govindb1.396432156444516E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies
Hi All,

I want to send multiple attachments to salesforce using Bulk API.

please tell me what should be the endpoint in this case,what should be my CSV format ,what all headers I'll be including and other stuff if you know which could help me

Thanks in advance!!
Hi All,

I want to send multiple attachments to salesforce using Bulk API.

please tell me what should be the endpoint in this case,what should be my CSV format ,what all headers I'll be including and other stuff if you know which could help me

Thanks in advance!!

HI

 

 

I have created a Tar file which has reuqest.txt and my Binary Attachment, but using the sample code which has been provided in Bulk API i am unable to insert Attachments.

 

I have converted the content type to :job.setContentType(ContentType.ZIP_CSV); and used connection.createBatchFromZipStream(jobInfo, tmpInputStream); .  I am getting the exception stateMessage='InvalidBatch : Referenced file "request.txt" is missing or is a directory'. 

 

Content in request.txt is

Name,ParentId,Body
Test.pdf,a0O9000000C4UujEAF,#Test.pdf

 

Please let me know is there any way to insert Binary File using Bulk APi

 

Regards

Bharghav

Hello,

 

I'm trying to add a batch to an existing job using the Bulk API from C#.  I've created the job and can get info on it, but am running into a problem when attempting to add a batch of data to it.

 

Here's the code.  The problem is that at run time the call to this line never returns:

Stream datastream = request.GetRequestStream();

 

This only happens when the url on the request includes the "batch" at the end (see first line of code).  The JobID parameter is valid, is an open job, and works in a separate call to get info.

 

Does anyone know what the problem might be?

 

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://na12-api.salesforce.com/services/async/23.0/job/" + JobID + "/batch");
            request.Method = WebRequestMethods.Http.Post;
            request.ContentType = "application/xml; charset=UTF-8";
            request.Headers.Add("X-SFDC-Session", _SessionID);
            request.KeepAlive = false;
            request.Host = "na12.salesforce.com";
            request.UserAgent = ".NET Framework Test Client";
            request.Accept = "application/xml";

            string body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";
            body += "<sObjects xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">";
            body += "  <sObject>";
            body += "    <description>Created from Bulk API on Wed Jan 4 2012</description>";
            body += "    <name>[Bulk API] Account 0 (batch 0)</name>";
            body += "  </sObject>";
            body += "  <sObject>";
            body += "    <description>Created from Bulk API on Wed Jan 4 2012</description>";
            body += "    <name>[Bulk API] Account 1 (batch 0)</name>";
            body += "  </sObject>";
            body += "</sObjects>";

            //Convert the body of request into a byte array
            byte[] byteArray = Encoding.UTF8.GetBytes(body);

            //Set the length
            request.ContentLength = byteArray.Length;

            //Write the body to the request by using a datastream
            //This line never returns....
            Stream datastream = request.GetRequestStream();
            datastream.Write(byteArray, 0, byteArray.Length);
            datastream.Close();

            //Call the service and get the response as a data stream
            WebResponse response = request.GetResponse();
            datastream = response.GetResponseStream();
            StreamReader reader = new StreamReader(datastream);
            string responseFromServer = reader.ReadToEnd();

            response.Close();

 

 

 

All,

I am using the Bulk Data Api to upsert a large number of records.  If one of those records fails I would not like the successful changes commited.  Is there a way to achieve this.  On the BulkConnection I see there is an abortJob method.  If I abort a job after it has already run through a few batchs will be undo the changes that have already been made?  Is there any easier way to do this?  Thanks in advance for any help. 

Does anyone know how to use Bulk API in C#?

the Web Service API can only update max 200 records at once.

Bulk API can update 10,000 records at once.

I only find sample code using Java.

Thanks.

 

  • October 27, 2010
  • Like
  • 0