Hi all, I’ve created a simple bpmn file which has a single task to send a http post message to MS Team channel. I’m using a task listener with the event type ‘Complete’. However, when I execute the flow the I receive an error of bad request with the status code 400.
I’ve tested the same code on a separate java console application and it works there just fine. But the same code doesn’t seem to work on camunda engine. Not sure where I did wrong.
Here’s the code of me calling the HTTP Post method:
public static void POSTCall(String url, String authorization, String body) throws IOException {
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
//httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
httpPost.setHeader("Authorization", authorization);
StringEntity stringEntity = new StringEntity(body);
httpPost.setEntity(stringEntity);
System.out.println("Executing request " + httpPost.getRequestLine());
HttpResponse response = httpclient.execute(httpPost);
System.out.println(response.getStatusLine().getReasonPhrase());
System.out.println("Status Code: " + response.getStatusLine().getStatusCode());
System.out.println("----------------------------------------");
}
}
and in the pom.xml file I’m using the following dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>