title: java.io.IOException: Unexpected response code for CONNECT: 400
body: <p>I am using Okhttp client to get the OAuth 2.0 token based on a Rest API. </p>
  
  <p>When I deploy it over Weblogic 12c its showing the error <strong>java.io.IOException: Unexpected response code for CONNECT: 400</strong></p>
  
  <p>I have tried to change the implementation and header method methods in different styles might be my request is failing because I am providing wrong credentials but nothing changed.</p>
  
  <p>Can anybody suggest what I am doing wrong in my code?</p>
  
  <p>Client Code</p>
  
  <pre><code>public String Post (String url, String json) throws IOException {
  
          Response response = null;
          try {
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; Posting method...");
  
          RequestBody body = RequestBody.create(JSON, json);
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; body: " + body);
  
          Request request = new Request.Builder().url(url).post(body).build();
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; request: " + request);
          response = client.newCall(request).execute();
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; returning: " + response.toString());
  
          }
          catch (Exception e) {
              logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; exception in WebServiceClient: " + e);
          }
  
          return response.body().string();
  
      }
  
  @GET
      @Path("/fundTransfer")
      @Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
      public String soapCaller() throws IOException, JSONException  {
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; Inside the client method");
  
          String json = new StringBuilder()
                  .append("{")
                  .append("\"grant_type\":\"client_credentials\",")
                  .append("\"client_id\":\"0146b9a4-7e99-4c83-8e9e-6049cfec55da\",")
                  .append("\"client_secret\":\"nY3oL5xQ3bJ8yT3nC1nV5bY4mY6eW7yP1nY6dS6rQ2nE5iR0rM\",")
                  .append("\"scope\":\"ABLApis\"")
                  .append("}").toString();
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; JSON &gt;&gt;&gt; " + json.toString());
  
          String response = Post("https://221.120.211.69:443/abl-api/uat/oauth2/token", json);
  
          logger.info("FMS WEBSERVICE LOG &gt;&gt;&gt; response &gt;&gt;&gt; " + response);
  
          return response;
  
      }
  </code></pre>
  
  <p>I am using postman to hit the GET Request with this URL: http:///FMS_WEB_SERVICES/fmsServices/fundTransfer</p>