I have been successfully able to use REST API for my application but I found that Bulk API will be better for my application. So, now I am trying to switch to Bulk API but I am stuck at the first step. I am not able to create new job. This is the error I am getting:
<?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>
This is the job.txt file I am using:
<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<operation>insert</operation>
<object>Account</object>
<contentType>CSV</contentType>
</jobInfo>
I also used my custom object that I created in my account (Statement_c) but that also not work.
This is the code I am using:
open_job($instance_url, $access_token);
function open_job($instance_url, $session_id){
$url = "$instance_url/services/async/26.0/job";
$content = array("file"=>"@job.txt");
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-SFDC-Session: $session_id",
"Content-type: application/xml; charset=UTF-8"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
$response = curl_exec($curl);
echo $response;
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo $status;
}
Few things that I made sure but if you think they could still be the problem let me know and I will check again:
1> job.txt data is being sent to the post and their is no problem with that.
2> session id and instance url are right.
I am not sure if I am using right API version. Please tell me how to find that?
Please tell me where am I wrong?