import java.util.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
HttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://localhost:8080/AppContextName/rest/process-definition/key/"+processInstanceKey+"/start");
String encoding = Base64.getEncoder().encodeToString(("admin:admin").getBytes());
// admin:admin is username:password
logger.info("encoding: "+encoding);
HttpEntity entity = new StringEntity("{}");
request.setEntity(entity);
request.setHeader("Authorization", "Basic " + encoding);
request.addHeader("Content-Type", "application/json");
HttpResponse response = client.execute(request);
System.out.println("Response String: "+response.toString());
System.out.println("Response Code: "+response.getStatusLine().getStatusCode());
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
HttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://localhost:8080/AppContextName/rest/process-definition/key/"+processInstanceKey+"/start");
String encoding = Base64.getEncoder().encodeToString(("admin:admin").getBytes());
// admin:admin is username:password
logger.info("encoding: "+encoding);
HttpEntity entity = new StringEntity("{}");
request.setEntity(entity);
request.setHeader("Authorization", "Basic " + encoding);
request.addHeader("Content-Type", "application/json");
HttpResponse response = client.execute(request);
System.out.println("Response String: "+response.toString());
System.out.println("Response Code: "+response.getStatusLine().getStatusCode());
No comments:
Post a Comment