title: jersey java client returning HTTP error code : 406
body: <p>I am doing a REST Call to a Teamcity URI, to gte the lastSuccessful build Number but getting 406. If i use the same URI in Chrome's REST Console, i get the correct String ( Which is the latest Build Number </p>
  
  <pre><code>import com.sun.jersey.api.client.Client;
  import com.sun.jersey.api.client.ClientResponse;
  import com.sun.jersey.api.client.WebResource;
  import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
  
  public class LastSuccessBuildNum {
  
      public static void main(String[] args) {
  
          try {
  
              Client client = Client.create();
              // client basic auth demonstration 
              client.addFilter(new HTTPBasicAuthFilter("username", "password"));
  
              WebResource webResource = client
                      .resource("http://localteamcity.com/teamcity/app/rest/buildTypes/id:bt26/builds/status:SUCCESS/number");
              ClientResponse response = webResource.accept("application/json")
                      .get(ClientResponse.class);
  
              if (response.getStatus() != 200) {
                  throw new RuntimeException("Failed : HTTP error code : "
                          + response.getStatus());
              }
  
              String output = response.getEntity(String.class);
  
              System.out.println("Output from Server .... \n");
              System.out.println(output);
          } catch (Exception e) {
  
              e.printStackTrace();
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>stdout:</p>
  
  <pre><code>java.lang.RuntimeException: Failed : HTTP error code : 406
      at LastSuccessBuildNum.main(LastSuccessBuildNum.java:22)
  </code></pre>