Skip to main content
Hi all, 

 

I want to create a query job using Bulk API. I have logged in succesfully in my sandbox using curl. I now have a sessionId and a serverURL returned by Salesforce.

 

I have an XML that creates a query job:

 

create-query-job.xml

 

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

 

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

 

<operation>query</operation>

 

<object>Account</object>

 

<concurrencyMode>Parallel</concurrencyMode>

 

<contentType>CSV</contentType> </jobInfo>

 

My curl statement is:

 

curl -H "X-SFDC-Session: 0012010!ASAAA.912AASAVASAAS" -H "Content-Type: application/xml; charset=UTF-8" -D @create-query-job.xml https://instance--Dev.my.salesforce.com/services/async/50.0/job

 

For security reasons, I have not pasted the real session Id or the instance name, but you get it :) I read in some documentation that on Mac (which I'm using), you need to either escape the exclamation point on the sessionId (tried - same error) or enclose the sessionId in single quotes (tried->Invalid session id error this time).

 

So trying this, I get the error:

 

<?xml version="1.0" encoding="UTF-8"?><error xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <exceptionCode>InvalidUrl</exceptionCode>

 

<exceptionMessage>Create Job must be a POST request</exceptionMessage>

 

How can I fix this and create the Job, returning the jobId ? Thank you for your answer!
3 respostas
  1. 23 de dez. de 2020, 23:44
    Hi Razvan,

     

    You need to escape ! In session Id.

     

    Here is an example of the code I'm actually using.

     

    curl -s -S --compressed -tlsv1.2 --cacert ./cacert.pem https://xxxx--partial.my.salesforce.com/services/async/50.0/job -H "X-SFDC-Session: xxxxxxxxxxxx\!AQ0AQKQP6jYLJJPOZAGA9jK8svogZubjiy51I6m9lJ3NdtI53tD9" -H "Content-Type: application/xml; charset=UTF-8" -d @/tmp/tmp2121-job_xml
0/9000