A simple bulk API which I am trying to create a JOB, and I am getting the status "NOT FOUND" and code: 400.

The same request working in the Workbench. Not sure what I am missing.


System.HttpResponse[Status=Not Found, StatusCode=404]

private static final string RESOURCE_URI = '/services/data/46.0/jobs/ingest';

    public static HTTPResponse createJob(String method){
        String baseURL = URL.getSalesforceBaseUrl().toExternalForm();
        String endpoint = baseURL+RESOURCE_URI;        

        String reqBody ='{"operation" : "insert","object" : "Account","contentType" : "CSV","lineEnding" : "CRLF"}';

        HttpRequest req = new HttpRequest();  
        req.setHeader('Content-Type', 'application/json; charset=UTF-8');
        req.setHeader('Accept', 'application/json');
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());

        Http httpReq = new Http();  
        HTTPResponse res = new HttpResponse();
            res = httpReq.send(req);   
            System.debug('endpoint: '+res.toString());        
        }catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
        return res;

  • When are you getting this error? Are you running it through anonymous apex and what are you passing as the "method" in the parameter Commented Oct 1, 2019 at 20:23
  • yes, anonymous. bulkApiController.createJob('POST')
    – Ajay
    Commented Oct 1, 2019 at 21:12
  • Do you still get the same issue if you change the 'Content-Type' header to be application/xml? developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/… Commented Oct 1, 2019 at 21:34
  • yes, I get the same issue, even though I change the header.
    – Ajay
    Commented Oct 4, 2019 at 23:59

1 Answer 1


We have to add v to the version to work. /services/data/v46.0/jobs/ingest

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .