• Frantz Carion
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 9
    Replies
 Hi all,

I'm trying to create a job to update account data via the bulk API matching on the salesforce id.
I could create the job and the batch ok, however i continuously get an error when the batch tries to run: it keeps telling me that the salesforce id field available in the CSV file, whatever the way i named it:
I've tried Id, RecordId, id (in lower case), AccountNumber and for all 4 tentatives, i got the same error message.
I need to be able to mass-update data using the salesforce id (the data i've got was pulled out of salesforce with the SOAP API, retaining the field names the way they are provided by the SOAP API) and can't rely on external id (i'll be always pulling out data from salesforce first, therefore i'll have the salesforce id).

I've been struggling on this error since beginning of the week, unable to find relevant information on using salesforce id in bulk API update specifically. I would be really grateful if someone could help.

Thx in advance
Is it possible to use the Account.Id (or the primary key (=Id) field of the updated table in general) as the match key when running an update via the bulk API?

If yes, how to do so since the tests i've done with a simple CSV file with 2 columns failed (header looked like this: Id,Name)
The status message on the batch entry shows : "InvalidBatch:  Field name not found : Id"
As if it could not find the Id column in Salesforce's Account table.

Please advise
Hi all,
I'm currently trying to code an upload facility to salesforce using the Bulk API, however my efforts are in vain so far as i keep getting error 400 Bad Request InvalidJob Unable to Parse job when running the post request to create the job.

I believe, thx to another post i could see, that this is due to the URL use to parse the request that is not correct. In my case, i've tried with https://emea.salesforce.com/services/async/30.0/job

this is based on the instance i get from connecting through the SOAP Api's loginresult serverURL and the API Version showing in my WDSL Partenr file. I've seen sites that mentions emea.salesforce.com maps to eu0-api.salesforce.com when using API, but oddly enough when trying with this i encounter the exact same error.

here below the code i'm using to try to add a job entry and parse the web request

private static string AddJob(SforceService binding, string sOperation, string sObjectName)
        {
            string str = "", reqURL = "";
            byte[] bytes = null;
            XmlDocument reqDoc = null;
            XmlDocument responseXmlDoc = new XmlDocument();

            str = "" 
                + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
                + "<jobInfo xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">"
                + "   <operation></operation>"
                + "   <object></object>"
                + "   <contentType>CSV</contentType>"
                + "</jobInfo>";

            reqURL = "https://eu0-api.salesforce.com/services/async/30.0/job";
            reqDoc = new XmlDocument();
            reqDoc.LoadXml(str); 

            //xml modifications
            reqDoc.GetElementsByTagName("operation")[0].InnerText = sOperation;
            reqDoc.GetElementsByTagName("object")[0].InnerText = sObjectName;
            bytes = System.Text.Encoding.ASCII.GetBytes(reqDoc.InnerXml);

            using (Stream respStream = Post(bytes, reqURL, binding.SessionHeaderValue.sessionId, "POST", "text/csv; charset=UTF-8"))
            {
                responseXmlDoc.Load(respStream);
                string sJobId = (responseXmlDoc != null ? responseXmlDoc.GetElementsByTagName("id")[0].InnerText : "");
                return sJobId;
            }
        }

private static Stream Post(byte[] bytes, string reqURL, string sSessionId, string sMethod, string sContentType)
        {
            WebRequest req = WebRequest.Create(reqURL);
            req.Method = sMethod;
            req.ContentType = sContentType;
            req.Headers.Add("X-SFDC-Session: " + sSessionId);

            if (bytes != null)
            {
                req.ContentLength = bytes.Length;
                System.IO.Stream strmHttpContent = req.GetRequestStream();
                strmHttpContent.Write(bytes, 0, bytes.Length);
                strmHttpContent.Close();
            }

            string sServerResponse;
            WebResponse resp = null;

            try
            {
                resp = req.GetResponse();

                if (((HttpWebResponse)resp).StatusCode == HttpStatusCode.OK)
                {
                    Stream dataStream = resp.GetResponseStream();
                    StreamReader reader = new StreamReader(dataStream);
                    sServerResponse = reader.ReadToEnd();
                    resp.Close();
                }
            }
            catch (WebException ex)
            {
                using (WebResponse errorresp = ex.Response)
                {
                    HttpWebResponse httpresp = (HttpWebResponse)errorresp;
                    sServerResponse = string.Format("Error code: {0} ", httpresp.StatusCode);

                    using (Stream data = errorresp.GetResponseStream())
                    {
                        sServerResponse += new StreamReader(data).ReadToEnd();
                    }
                }
            }

            return resp.GetResponseStream();
        }

i would be grateful if any of you could guide me on this as i've been searching extensively all day with no progress so far.

 Hi all,

I'm trying to create a job to update account data via the bulk API matching on the salesforce id.
I could create the job and the batch ok, however i continuously get an error when the batch tries to run: it keeps telling me that the salesforce id field available in the CSV file, whatever the way i named it:
I've tried Id, RecordId, id (in lower case), AccountNumber and for all 4 tentatives, i got the same error message.
I need to be able to mass-update data using the salesforce id (the data i've got was pulled out of salesforce with the SOAP API, retaining the field names the way they are provided by the SOAP API) and can't rely on external id (i'll be always pulling out data from salesforce first, therefore i'll have the salesforce id).

I've been struggling on this error since beginning of the week, unable to find relevant information on using salesforce id in bulk API update specifically. I would be really grateful if someone could help.

Thx in advance
Is it possible to use the Account.Id (or the primary key (=Id) field of the updated table in general) as the match key when running an update via the bulk API?

If yes, how to do so since the tests i've done with a simple CSV file with 2 columns failed (header looked like this: Id,Name)
The status message on the batch entry shows : "InvalidBatch:  Field name not found : Id"
As if it could not find the Id column in Salesforce's Account table.

Please advise
Hi all,
I'm currently trying to code an upload facility to salesforce using the Bulk API, however my efforts are in vain so far as i keep getting error 400 Bad Request InvalidJob Unable to Parse job when running the post request to create the job.

I believe, thx to another post i could see, that this is due to the URL use to parse the request that is not correct. In my case, i've tried with https://emea.salesforce.com/services/async/30.0/job

this is based on the instance i get from connecting through the SOAP Api's loginresult serverURL and the API Version showing in my WDSL Partenr file. I've seen sites that mentions emea.salesforce.com maps to eu0-api.salesforce.com when using API, but oddly enough when trying with this i encounter the exact same error.

here below the code i'm using to try to add a job entry and parse the web request

private static string AddJob(SforceService binding, string sOperation, string sObjectName)
        {
            string str = "", reqURL = "";
            byte[] bytes = null;
            XmlDocument reqDoc = null;
            XmlDocument responseXmlDoc = new XmlDocument();

            str = "" 
                + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
                + "<jobInfo xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">"
                + "   <operation></operation>"
                + "   <object></object>"
                + "   <contentType>CSV</contentType>"
                + "</jobInfo>";

            reqURL = "https://eu0-api.salesforce.com/services/async/30.0/job";
            reqDoc = new XmlDocument();
            reqDoc.LoadXml(str); 

            //xml modifications
            reqDoc.GetElementsByTagName("operation")[0].InnerText = sOperation;
            reqDoc.GetElementsByTagName("object")[0].InnerText = sObjectName;
            bytes = System.Text.Encoding.ASCII.GetBytes(reqDoc.InnerXml);

            using (Stream respStream = Post(bytes, reqURL, binding.SessionHeaderValue.sessionId, "POST", "text/csv; charset=UTF-8"))
            {
                responseXmlDoc.Load(respStream);
                string sJobId = (responseXmlDoc != null ? responseXmlDoc.GetElementsByTagName("id")[0].InnerText : "");
                return sJobId;
            }
        }

private static Stream Post(byte[] bytes, string reqURL, string sSessionId, string sMethod, string sContentType)
        {
            WebRequest req = WebRequest.Create(reqURL);
            req.Method = sMethod;
            req.ContentType = sContentType;
            req.Headers.Add("X-SFDC-Session: " + sSessionId);

            if (bytes != null)
            {
                req.ContentLength = bytes.Length;
                System.IO.Stream strmHttpContent = req.GetRequestStream();
                strmHttpContent.Write(bytes, 0, bytes.Length);
                strmHttpContent.Close();
            }

            string sServerResponse;
            WebResponse resp = null;

            try
            {
                resp = req.GetResponse();

                if (((HttpWebResponse)resp).StatusCode == HttpStatusCode.OK)
                {
                    Stream dataStream = resp.GetResponseStream();
                    StreamReader reader = new StreamReader(dataStream);
                    sServerResponse = reader.ReadToEnd();
                    resp.Close();
                }
            }
            catch (WebException ex)
            {
                using (WebResponse errorresp = ex.Response)
                {
                    HttpWebResponse httpresp = (HttpWebResponse)errorresp;
                    sServerResponse = string.Format("Error code: {0} ", httpresp.StatusCode);

                    using (Stream data = errorresp.GetResponseStream())
                    {
                        sServerResponse += new StreamReader(data).ReadToEnd();
                    }
                }
            }

            return resp.GetResponseStream();
        }

i would be grateful if any of you could guide me on this as i've been searching extensively all day with no progress so far.