Exception in thread "main" java.lang.RuntimeException: Failed : HTTP error code : 405 at WebserviceTest.vrn.App.main(App.java:38)
<p>I am getting the above error while i am testing the the below given webservice using java.I am not getting the response.</p>

<p>Webservice is <a href="http://services.groupkt.com/state/get/IND/all" rel="nofollow">http://services.groupkt.com/state/get/IND/all</a></p>

<p>My code is</p>

<pre><code>try {

        // create HTTP Client
        HttpClient httpClient = HttpClientBuilder.create().build();

        // Create new getRequest with below mentioned URL
        HttpPost getRequest = new HttpPost("http://services.groupkt.com/state/get/IND/all");

        // Add additional header to getRequest which accepts application/xml data
        getRequest.addHeader("accept", "application/xml");

        // Execute your request and catch response
        HttpResponse response = httpClient.execute(getRequest);

        // Check for HTTP response code: 200 = success
        if (response.getStatusLine().getStatusCode() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
        }

        // Get-Capture Complete application/xml body response
        BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
        String output;
        System.out.println("============Output:============");

        // Simply iterate through XML response and show on console.
        while ((output = br.readLine()) != null) {
            System.out.println(output);
        }

    } catch (ClientProtocolException e) {
        e.printStackTrace();

    } catch (IOException e) {
        e.printStackTrace();
    }
</code></pre>

<p>Error is thrown here</p>

<pre><code>if (response.getStatusLine().getStatusCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
    }
</code></pre>