+ Start a Discussion
SimonHoldernessSimonHolderness 

bulk upsert fails with "Unable to parse Job"

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

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

Turns out you need to put the contentType element after the externalIdFieldName, e.g.

 

<?xml version="1.0" encoding="UTF-8"?>

<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">

    <operation>upsert</operation>

    <object>Foo__c</object>

<externalIdFieldName>myExtId__c</externalIdFieldName>

<contentType>CSV</contentType>

</jobInfo> 

All Answers

SuperfellSuperfell

Have you looked at the reference section of the docs ?

 

The externalId should be in an externalIdFieldName element

SimonHoldernessSimonHolderness

I get the same with

 

<?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>

SuperfellSuperfell

Turns out you need to put the contentType element after the externalIdFieldName, e.g.

 

<?xml version="1.0" encoding="UTF-8"?>

<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">

    <operation>upsert</operation>

    <object>Foo__c</object>

<externalIdFieldName>myExtId__c</externalIdFieldName>

<contentType>CSV</contentType>

</jobInfo> 

This was selected as the best answer
SimonHoldernessSimonHolderness

Brilliant, works a treat

Thanks

DDG_LJUDDG_LJU

FUSTRATION Abounds!!!

Adam CadamAdam Cadam
Thank you this - this works and saved me some serious hair pulling!
Another bit of SF Craziness.
I know XML elements can be specified in an order, but they don't have to be, and I can't see why they'd want these tags in a specific order.
Surely, if the 'operation' is 'upsert' then it should look for the externalIdFieldName element rgardless of where the elemnt appears in relation to other elements!