+ Start a Discussion
Jeffrey ZhangJeffrey Zhang 

bulk api async api exception invalidurl destination url not set.

Getting this error when trying to do the bulk api example on developer.salesforce.com 
 
2017-02-14 15:03:03.381 ERROR 19228 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is [AsyncApiException  exceptionCode='InvalidUrl'
 exceptionMessage='Destination URL not reset. The URL returned from login must be set'
]
] with root cause

com.sforce.async.AsyncApiException: InvalidUrl : Destination URL not reset. The URL returned from login must be set
	at com.sforce.async.BulkConnection.parseAndThrowException(BulkConnection.java:125) ~[wsc-23-min.jar:23-min]
	at com.sforce.async.BulkConnection.createOrUpdateJob(BulkConnection.java:109) ~[wsc-23-min.jar:23-min]
	at com.sforce.async.BulkConnection.createJob(BulkConnection.java:89) ~[wsc-23-min.jar:23-min]
	at ves.sfdc.service.AccountService.doBulkQuery(AccountService.java:183) ~[classes/:na]

it's failing at the Createjob here:
 
public boolean login() {
			  boolean success = false;
			  
			  String userId ="awefawf";
			  String passwd = "awfa";
			  String soapAuthEndPoint = "https://test.salesforce.com/services/Soap/c/28.0";
			  //String bulkAuthEndPoint = "https://test.salesforce.com/services/Soap/async/28.0";
			  String bulkAuthEndPoint =soapAuthEndPoint.substring(0, soapAuthEndPoint.indexOf("Soap/")) + "async/28.0";

			 String proxy = "wafaefa";
			

			  try {
			    ConnectorConfig config = new ConnectorConfig();
			    config.setUsername(userId);
			    config.setPassword(passwd);
			    config.setAuthEndpoint(soapAuthEndPoint);
			    config.setCompression(true);
			    config.setTraceFile("traceLogs.txt");
			    config.setTraceMessage(true);
			    config.setPrettyPrintXml(true);
				if ((proxy!=null) && (!proxy.equals(""))) {
					config.setProxy(proxy, 80);
				}
			    config.setRestEndpoint(bulkAuthEndPoint);

			    System.out.println("AuthEndpoint: " + 
			        config.getRestEndpoint());
			    EnterpriseConnection connection = new EnterpriseConnection(config);
			    System.out.println("SessionID: " + config.getSessionId());
			     bulkConnection = new BulkConnection(config);
			    success = true;
			  } catch (AsyncApiException aae) {
			    aae.printStackTrace();
			  } catch (ConnectionException ce) {
			    ce.printStackTrace();
			  } catch (FileNotFoundException fnfe) {
			    fnfe.printStackTrace();
			  }
			  return success;
			}
		public void doBulkQuery() throws AsyncApiException, InterruptedException
		{
//			SForceConnector sfc = new SForceConnector();
//			EnterpriseConnection connection = sfc.getConnection();
			
			if ( ! login() ) {

				    return;

				  }

			JobInfo job = new JobInfo();
			    job.setObject("Account");
			    job.setOperation(OperationEnum.query);
			    job.setConcurrencyMode(ConcurrencyMode.Parallel);
			    job.setContentType(ContentType.CSV);
			    job = bulkConnection.createJob(job);
			    assert job.getId() != null;

i'm not able to find anyone else that got this error from googling which is surprising. I wonder if there is something obvious that I missed. The enterpriseconnection is fine, just something is off at createjob. 

Thanks!