I am trying to make a HTTP request with Camunda’s HTTP Connector, but payload is not sent. When I am using OkHttp framework for the same request, payload is delivered. What could be the issue in case of HTTP Connector?
The method’s I am using are following:
public void postExampleWithHttpConnector() {
HttpConnector http = Connectors.getConnector(HttpConnector.ID);
HttpResponse response = http.createRequest()
.post()
.contentType("application/json")
.payload("{\"jsonrpc\":\"2.0\",\"method\":\"changeDetail\"}")
.url("http://posttestserver.com/post.php")
.execute();
System.out.println(response.getResponse());
response.close();
}
public void postExampleWithOkHttpClient() {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"jsonrpc\":\"2.0\",\"method\":\"changeDetail\"}");
Request request = new Request.Builder()
.url("http://posttestserver.com/post.php")
.post(body)
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
response.close();
} catch (Exception exception) {
System.out.println(exception.getMessage());
}
}