• SimonHolderness
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

When I add the tag for the externalIDFieldName (also tried externalIdFieldName)

 

<?xml version="1.0" encoding="utf-8"?>
<jobInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.force.com/2009/06/asyncapi/dataload">
  <operation>upsert</operation>
  <object>Prospect__c</object>
  <contentType>CSV</contentType>
  <externalIDFieldName>Urn__c</externalIDFieldName>
</jobInfo>

 

and send this to the API, I get back

 

<?xml version="1.0" encoding="UTF-8"?><error
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <exceptionCode>InvalidJob</exceptionCode>
 <exceptionMessage>Unable to parse Job</exceptionMessage>
</error>

 

If I leave the externalIdFieldName tag out

 

<?xml version="1.0" encoding="utf-8"?>
<jobInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.force.com/2009/06/asyncapi/dataload">
  <operation>upsert</operation>
  <object>Prospect__c</object>
  <contentType>CSV</contentType>
</jobInfo>

 

I get

 

<?xml version="1.0" encoding="UTF-8"?><error
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <exceptionCode>InvalidJob</exceptionCode>
 <exceptionMessage>External ID was blank for Prospect__c. An External ID must be specified for upsert.</exceptionMessage>
</error>

 

Any ideas

 

Also, is there a resource that I can use to get the full XML specification for these batch requests and responses?

 

Thanks

Simon

I am trying to use a post request to start a batch upsert.  I have managed to get this to work using Curl, but I always get a 400 Bad Response when using the native HttpWebRequest method

 

I am passing the postData as UTF-8 encoded, and include the following for the contentType and headers

 

Content-Type: application/xml; charset=UTF-8
X-SFDC-Session: 00D700000008rXl!AQMAQA1rjn2jPYeSQuRoChquzvncucoqSNHVSUydo1eM0eSV3PKmSYE0QoD8gkSxBb2tuaT3wd8Dd1fr_YahMGhtxYO7m7u2 

 

Below is the code; when I look at the request that works with Curl and my request in tcpTrace, they look identical.

 

public static string PostData(string url, byte[] postData, string contentType, KeyValuePair<string, string>[] headers, ITaskProgress progress)

{

int length = postData.Length;

Uri uri = new Uri(url);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

request.Method = "POST";request.ServicePoint.Expect100Continue =

false;

request.ContentType = contentType;

request.ContentLength = length;

request.ReadWriteTimeout = Timeout;

request.Timeout = Timeout;

request.AllowWriteStreamBuffering = false;

request.Accept = "application/xml";request.UserAgent =

"Salesforce Web Service Connector"; if (headers != null)

{

foreach (KeyValuePair<string, string> header in headers)

request.Headers.Add(header.Key, header.Value);

}

if (progress != null)

progress.CurrentTaskProgress = 0;

using (Stream writeStream = request.GetRequestStream())

{

int bytesSent = 0; while (bytesSent < length)

{

int bytesToSend = Math.Min(ChunkSize, length - bytesSent);

writeStream.Write(postData, bytesSent, bytesToSend);

bytesSent += bytesToSend;

if (progress != null)progress.CurrentTaskProgress = (int)((long)bytesSent * 100) / length;

}

}

if (progress != null)

progress.CurrentTaskProgress = 100;

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

...

 

Here is the actual post sent

 

POST /services/async/18.0/job HTTP/1.1
Content-Type: application/xml; charset=UTF-8
Accept: application/xml
User-Agent: Salesforce Web Service Connector
X-SFDC-Session: 00D700000008rXl!AQMAQA1rjn2jPYeSQuRoChquzvncucoqSNHVSUydo1eM0eSV3PKmSYE0QoD8gkSxBb2tuaT3wd8Dd1fr_YahMGhtxYO7m7u2
Host: localhost:8080
Content-Length: 626
Connection: Keep-Alive

<?xml version="1.0" encoding="utf-8"?><jobInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.force.com/2009/06/asyncapi/dataload">  <operation>upsert</operation>  <object>Leads</object>  <contentType>CSV</contentType>  <numberBatchesQueued>0</numberBatchesQueued>  <numberBatchesInProgress>0</numberBatchesInProgress>  <numberBatchesCompleted>0</numberBatchesCompleted>  <numberBatchesFailed>0</numberBatchesFailed>  <numberBatchesTotal>0</numberBatchesTotal>  <numberRecordsProcessed>0</numberRecordsProcessed>  <numberRetries>0</numberRetries></jobInfo>

 

Very very strange

When I add the tag for the externalIDFieldName (also tried externalIdFieldName)

 

<?xml version="1.0" encoding="utf-8"?>
<jobInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.force.com/2009/06/asyncapi/dataload">
  <operation>upsert</operation>
  <object>Prospect__c</object>
  <contentType>CSV</contentType>
  <externalIDFieldName>Urn__c</externalIDFieldName>
</jobInfo>

 

and send this to the API, I get back

 

<?xml version="1.0" encoding="UTF-8"?><error
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <exceptionCode>InvalidJob</exceptionCode>
 <exceptionMessage>Unable to parse Job</exceptionMessage>
</error>

 

If I leave the externalIdFieldName tag out

 

<?xml version="1.0" encoding="utf-8"?>
<jobInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.force.com/2009/06/asyncapi/dataload">
  <operation>upsert</operation>
  <object>Prospect__c</object>
  <contentType>CSV</contentType>
</jobInfo>

 

I get

 

<?xml version="1.0" encoding="UTF-8"?><error
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <exceptionCode>InvalidJob</exceptionCode>
 <exceptionMessage>External ID was blank for Prospect__c. An External ID must be specified for upsert.</exceptionMessage>
</error>

 

Any ideas

 

Also, is there a resource that I can use to get the full XML specification for these batch requests and responses?

 

Thanks

Simon

I am trying to use a post request to start a batch upsert.  I have managed to get this to work using Curl, but I always get a 400 Bad Response when using the native HttpWebRequest method

 

I am passing the postData as UTF-8 encoded, and include the following for the contentType and headers

 

Content-Type: application/xml; charset=UTF-8
X-SFDC-Session: 00D700000008rXl!AQMAQA1rjn2jPYeSQuRoChquzvncucoqSNHVSUydo1eM0eSV3PKmSYE0QoD8gkSxBb2tuaT3wd8Dd1fr_YahMGhtxYO7m7u2 

 

Below is the code; when I look at the request that works with Curl and my request in tcpTrace, they look identical.

 

public static string PostData(string url, byte[] postData, string contentType, KeyValuePair<string, string>[] headers, ITaskProgress progress)

{

int length = postData.Length;

Uri uri = new Uri(url);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

request.Method = "POST";request.ServicePoint.Expect100Continue =

false;

request.ContentType = contentType;

request.ContentLength = length;

request.ReadWriteTimeout = Timeout;

request.Timeout = Timeout;

request.AllowWriteStreamBuffering = false;

request.Accept = "application/xml";request.UserAgent =

"Salesforce Web Service Connector"; if (headers != null)

{

foreach (KeyValuePair<string, string> header in headers)

request.Headers.Add(header.Key, header.Value);

}

if (progress != null)

progress.CurrentTaskProgress = 0;

using (Stream writeStream = request.GetRequestStream())

{

int bytesSent = 0; while (bytesSent < length)

{

int bytesToSend = Math.Min(ChunkSize, length - bytesSent);

writeStream.Write(postData, bytesSent, bytesToSend);

bytesSent += bytesToSend;

if (progress != null)progress.CurrentTaskProgress = (int)((long)bytesSent * 100) / length;

}

}

if (progress != null)

progress.CurrentTaskProgress = 100;

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

...

 

Here is the actual post sent

 

POST /services/async/18.0/job HTTP/1.1
Content-Type: application/xml; charset=UTF-8
Accept: application/xml
User-Agent: Salesforce Web Service Connector
X-SFDC-Session: 00D700000008rXl!AQMAQA1rjn2jPYeSQuRoChquzvncucoqSNHVSUydo1eM0eSV3PKmSYE0QoD8gkSxBb2tuaT3wd8Dd1fr_YahMGhtxYO7m7u2
Host: localhost:8080
Content-Length: 626
Connection: Keep-Alive

<?xml version="1.0" encoding="utf-8"?><jobInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.force.com/2009/06/asyncapi/dataload">  <operation>upsert</operation>  <object>Leads</object>  <contentType>CSV</contentType>  <numberBatchesQueued>0</numberBatchesQueued>  <numberBatchesInProgress>0</numberBatchesInProgress>  <numberBatchesCompleted>0</numberBatchesCompleted>  <numberBatchesFailed>0</numberBatchesFailed>  <numberBatchesTotal>0</numberBatchesTotal>  <numberRecordsProcessed>0</numberRecordsProcessed>  <numberRetries>0</numberRetries></jobInfo>

 

Very very strange