I am receiving an error org.apache.http.client.HttpResponseException: Bad Request when I try to run this program.
Could you please help me understand where I should modify the code ?
I am using the following libraries httpclient-4.4.1.jar httpcore-4.4.1.jar commons-logging-1.1.2.jar
org.apache.http.client.HttpResponseException: Bad Request
Here is the code :
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
public class Test {
public static void main(String args[]) throws Exception {
HttpClient httpclient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost("http://localhost:8080/engine-rest/process-definition/key/demo-scaling/start");
try {
StringEntity input = new StringEntity("(\"variables\":{}, \"businessKey\" : \"AAA001\")");
postRequest.addHeader("Accept", "application/json");
postRequest.setEntity(input);
postRequest.addHeader("Content-Type", "application/json");
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(postRequest, responseHandler);
System.out.println(responseBody);
} catch (Exception e) {
e.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
}
}
}