Need java code to test API response ? If API's need authentication

39 views Asked by At

Currently I am using the following code to get the response.

public static String LinkCheacker(String URLString) throws IOException {
        String Status;
        try {
            URL url = new URL(URLString);
            HttpURLConnection http = (HttpURLConnection) url.openConnection();
            http.setRequestMethod("GET");
            http.connect();
            Status = http.getResponseCode() + ":" + http.getResponseMessage();
            http.disconnect();
        } catch (Exception e) {
            Status = ":some error:" + e.getMessage();
        }
        return Status;
    }

I am having some more API's to test with the authentication (Login with userId, Password), How can I test them ? Please help me on this.

0

There are 0 answers