2

Though I can create jobs and add batches with the Bulk API, when I try to close a job Salesforce tells me that it can't parse by doing a POST request to https://INSTANCE_NAME-api.salesforce.com/services/async/29.0/job/JOB_ID with the following data:

<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xlmns="http://www.force.com/2009/06/asyncapi/dataload">
    <state>Closed</state>
</jobInfo>

and with the appropriate session headers (X-SFDC-Session: SESSION_ID) and content type (Content-Type: application/xml; charset=UTF-8), I get back a failure response:

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

I also tried posting to https://INSTANCE_NAME.salesforce.com/services/async/29.0/job/JOB_ID and received the same response.

When I do a GET request, I actually get back a successful response:

<?xml version="1.0" encoding="UTF-8"?><jobInfo
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <id>JOB_ID</id>
 <operation>insert</operation>
 <object>Contact</object>
 <createdById>SOME_ID</createdById>
 <createdDate>2014-01-06T23:56:13.000Z</createdDate>
 <systemModstamp>2014-01-06T23:56:13.000Z</systemModstamp>
 <state>Open</state>
 <concurrencyMode>Parallel</concurrencyMode>
 <contentType>CSV</contentType>
 <numberBatchesQueued>0</numberBatchesQueued>
 <numberBatchesInProgress>0</numberBatchesInProgress>
 <numberBatchesCompleted>0</numberBatchesCompleted>
 <numberBatchesFailed>0</numberBatchesFailed>
 <numberBatchesTotal>0</numberBatchesTotal>
 <numberRecordsProcessed>0</numberRecordsProcessed>
 <numberRetries>0</numberRetries>
 <apiVersion>29.0</apiVersion>
 <numberRecordsFailed>0</numberRecordsFailed>
 <totalProcessingTime>0</totalProcessingTime>
 <apiActiveProcessingTime>0</apiActiveProcessingTime>
 <apexProcessingTime>0</apexProcessingTime>
</jobInfo>

(edited out some of the information).

Any idea what I'm doing wrong? I believe I'm following the tutorial exactly.

I tried adding an id field to the request, like this:

<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xlmns="http://www.force.com/2009/06/asyncapi/dataload">
    <id>JOB_ID</id>
    <state>Closed</state>
</jobInfo>

But that didn't help either.

2

It turns out that you have to remove all whitespace from the request, so if you pass this, it will work:

<?xml version="1.0" encoding="UTF-8"?><jobInfo xlmns="http://www.force.com/2009/06/asyncapi/dataload"><state>Closed</state></jobInfo>

I had the idea from a developer forum post on a different API where one of the Salesforce people mentioned that adding extra whitespace to the xml could cause a request to fail (and they said they would fix it).

  • I have also experienced whitespace issues with column names. If you have an extra space in the column name of your csv file, the entire batch fails. – abhi Sep 29 '16 at 13:07
1

I was getting the same error when I passed the state as "closed". Please check you are writing "Closed" (with 'C' capital). This might help because SF bulk API do not parse the request if it is not it is not as per the SF BULK API standard.

similarly state "insert" should be all small.

Please check and let me know if you still facing any issues.

0

I am developing an Oracle BPEL process to upsert the product information and Translations into SFDC and while closing the Job I faced the exact same issue. "Invalid Job"

Solution

  • Create New Job
  • Post the Data for Upsert
  • ..... Usual process ......
  • ..... Usual process ......
  • Before closing, have to make sure that the job is completed, only once the job is completed, the particular request works

    <?xml version="1.0" encoding="UTF-8"?>
    <jobInfo xlmns="http://www.force.com/2009/06/asyncapi/dataload">
        <id>JOB_ID</id>
        <state>Closed</state>
    </jobInfo>
    
  • For time being, once I post a request for uploading batch, i have a wait signal of 10 secs before executing my close job request.

This is a crude approach, but for time being this seems to be working fine and thought will share this information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.