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 Oct 1 '19 at 20:23
  • yes, anonymous. bulkApiController.createJob('POST')
    – Ajay
    Oct 1 '19 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/… Oct 1 '19 at 21:34
  • yes, I get the same issue, even though I change the header.
    – Ajay
    Oct 4 '19 at 23:59

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

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.