0

I am trying to integrate a curl command within this java file to execute a Curl command tied into the message that "The Validation Test case failed", how do I integrate this to only send when the job fails and the email is triggered?

public class SendToMetricPipeline {

public static void sendMetric(String status, String environment, String dashboard, String remarks) {

    TimeZone tz = TimeZone.getTimeZone("UTC");
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    df.setTimeZone(tz);
    String today = df.format(new Date());

...

    if (postResult) {
        System.out.println("Data Successfully posted");
    } else {
        System.out.println("Data not sent");

        if (environment.equalsIgnoreCase("prod")) {
            EmailUtil.sendEmail("Application Validation Post Results Failed", " Validation Post Results Failed");

        }
    }

    //Send Email when the test case Fail
    if (status == "failed") {
        System.out.println("Validation Test Failed");

        if (environment.equalsIgnoreCase("prod")) {
            EmailUtil.sendEmail("The Validation Test case failed", " Validation Test Failed");
        }
    }
}

}

v27
  • 1
  • check similar answers: https://stackoverflow.com/questions/2586975/how-to-use-curl-in-java or https://stackoverflow.com/questions/116650/curl-equivalent-in-java – icrovett Jun 16 '21 at 14:58
  • 1
    Without sharing your code it won't be very easy to help you. Also do note, that this is wrong `status == "failed"`. – akortex Jun 16 '21 at 15:39
  • Edit your question and explain what you want your curl command to do. None of the code in your question indicates what URL you want to invoke, which HTTP method you want to use, which headers you want to supply, the type of the request body, or the expected type of the response body. – VGR Jun 16 '21 at 16:00

0 Answers0