title: Jersery REST client is returning HTTP error code : 500
body: <p>I need to create Jersey REST client. Here is my code:</p>
  
  <pre><code>    ClientConfig clientConfig = new DefaultClientConfig();
      Client client = Client.create(clientConfig);
      client.addFilter(new HTTPBasicAuthFilter(user_id, api_key));
      WebResource webResource = client.resource(uri);
  
      String inputString = "{ \"subject\" : \"Test\", \"message\" : \"Hello\", \"recipients\" : \"abc@gmail.com\" }";
  
      ClientResponse response =  webResource.accept(MediaType.APPLICATION_JSON)
              .type(MediaType.APPLICATION_JSON)
              .post(ClientResponse.class, inputString);
  
      // check response status code
      if (response.getStatus() != 200) {
          throw new RuntimeException("Failed : HTTP error code : "
                  + response.getStatus());
      }
  </code></pre>
  
  <p>Above code gives me below error:</p>
  
  <pre><code>Exception in thread "main" java.lang.RuntimeException: Failed : HTTP error code : 500
  </code></pre>
  
  <p>REST service is not developed by me. It is third party service. REST service says: </p>
  
  <p>API can be accessed over HTTPS with Basic HTTP Auth (the Authentication header for the requests, very standard for REST-like API). API requires HTTP POST.</p>
  
  <p>This is the CURL which is working fine:</p>
  
  <p>curl -u user_id:api_key -d "subject=API%20Test&amp;message=Hello&amp;recipients=abc@gmail.com" apiEndpointUri</p>
  
  <p>Please help me on Jersey REST client.</p>