0

Am trying to use spring RestTemplate to create a bulk API job. Below is the code

HttpHeaders headers= new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("sforce-enable-pk chunking","chunksize=10000");
headers.add("X-SFDC-Session","MYSESSIONID");

JSONObject jsonBody=new JSONObject();
jsonBody.put("operation","query");
jsonBody.put("Object","account");
jsonBody.put("contenttype","CSV");

HttpEntity<String> request=new HttpEntity<String>(jsonBody.toString,headers);
SimpleClientHttpRequestFactory factory=new SimpleClientHttpRequestFactory ();
InetSocketAddress inaddress=new InetSocketAddress("HOST",PORTNUMBER);
Proxy proxy=new Proxy(Proxy.Type.HTTP,inaddress);
factory.setProxy(proxy);

RestTemplate rt=new RestTemplate(factory);

try{
ResponseEntity<String> response=rt.exchage("URL",HttpMethod.POST,request,String.class);
}catch(RestClientException e){

}

The above code is failing with HTTP 400 Bad request. Please suggest,

1

This works

HTTP.Header['X-SFDC-Session'] := SalesForce_oauth_token['access_token'].Value;

HTTP.Open ('POST', '/services/async/38.0/job');

HTTP.Header['Content-Type'] := 'application/json';

HTTP.Header['Accept'] := 'application/json';

Cont_Object := TJSONOBJECT.Create

Cont_Object.AddString('operation','update');

Cont_Object.AddString('object','account');

Cont_Object.AddString('contentType','CSV');

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.