title: Why does my Web request get Truncated when using the newest versions of Retrofit / OkHttp
body: <p>Good day all, I recently updated my libraries and upgraded Retrofit and OkHttp. The new versions I am using include these imports / versions:</p>
  
  <p>1) Gson - compile 'com.google.code.gson:gson:2.7'</p>
  
  <p>2) OkHttp - compile 'com.squareup.okhttp3:okhttp:3.4.1'</p>
  
  <p>3) OkHttp Logging - compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'</p>
  
  <p>4) Retrofit - compile 'com.squareup.retrofit2:retrofit:2.1.0'</p>
  
  <p>5) Retrofit Gson Converter - compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'</p>
  
  <p>I had to change the structure of some of my actual calls, but other than that, my code remained mostly the same as it did from previous versions of these libraries (Retrofit / OkHttp 1). </p>
  
  <p>The problem I am having is that when I send an outbound call, it is essentially 'ignoring' the annotations for the paths.</p>
  
  <p>My Retrofit Client Class :</p>
  
  <pre><code>import com.google.gson.GsonBuilder;
  import com.google.gson.annotations.SerializedName;
  import java.io.IOException;
  import java.security.KeyManagementException;
  import java.security.KeyStore;
  import java.security.KeyStoreException;
  import java.security.NoSuchAlgorithmException;
  import java.util.Arrays;
  import java.util.concurrent.TimeUnit;
  import javax.net.ssl.SSLContext;
  import javax.net.ssl.SSLSocketFactory;
  import javax.net.ssl.TrustManager;
  import javax.net.ssl.TrustManagerFactory;
  import javax.net.ssl.X509TrustManager;
  import okhttp3.Interceptor;
  import okhttp3.OkHttpClient;
  import okhttp3.Request;
  import okhttp3.Response;
  import okhttp3.logging.HttpLoggingInterceptor;
  import retrofit2.GsonConverterFactory;
  import retrofit2.Retrofit;
  
  public class RetrofitClient {
  
      private static RetrofitService serviceClient;
  
      private static final String BASE_URL = "api.myapiurl.com";
      private static HttpLoggingInterceptor.Level httpLogLevel = HttpLoggingInterceptor.Level.BODY;
  
      static {
          buildAClient();
      }
  
      public static RetrofitService getServiceClient(){
          return serviceClient;
      }
  
      private static void buildAClient(){
  
          Interceptor interceptor = new Interceptor() {
              @Override
              public Response intercept(Interceptor.Chain chain) throws IOException {
                  Request.Builder builder = new Request.Builder();
                  Request original = chain.request();
                  builder.url(BASE_URL);
                  builder.addHeader("Content-Type", "application/json");
                  builder.method(original.method(), original.body());
                  Request newRequest = builder.build();
                  return chain.proceed(newRequest);
              }
          };
          HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
          logging.setLevel(httpLogLevel);
  
          OkHttpClient.Builder builder = new OkHttpClient.Builder();
          builder.readTimeout(60, TimeUnit.SECONDS);
          builder.writeTimeout(60, TimeUnit.SECONDS);
          builder.addInterceptor(interceptor);
          builder.addInterceptor(logging);
          builder = configureClient(builder);
  
          OkHttpClient client = builder.build();
  
          Retrofit.Builder myBuilder = new Retrofit.Builder();
          myBuilder.baseUrl(BASE_URL);
          Gson gson = new GsonBuilder()
                  .setLenient()
                  .setPrettyPrinting() 
                  .create();
          GsonConverterFactory factory = GsonConverterFactory.create(gson);
          myBuilder.addConverterFactory(factory);
          myBuilder.client(client);
          Retrofit retrofit = myBuilder.build();
          serviceClient = retrofit.create(RetrofitService.class);
  
      }
  
  
      /**
       * {@link okhttp3.OkHttpClient.Builder} &lt;-- sslSocketFactory
        */
      private static OkHttpClient.Builder configureClient(final OkHttpClient.Builder builder) {
              TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
                      TrustManagerFactory.getDefaultAlgorithm());
              trustManagerFactory.init((KeyStore) null);
              TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
              if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
                  throw new IllegalStateException("Unexpected default trust managers:"
                          + Arrays.toString(trustManagers));
              }
              X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
  
              SSLContext sslContext = SSLContext.getInstance("TLS");
              sslContext.init(null, new TrustManager[]{trustManager}, null);
              SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
  
              builder.sslSocketFactory(sslSocketFactory, trustManager);
          return builder;
      }
  }
  </code></pre>
  
  <p>My Retrofit Service Interface:</p>
  
  <pre><code>public interface RetrofitService {
      //Version Strings
      public static final String VERSION2 = "/v2";
  
      //Returns a list of Order Objects
      @GET(VERSION2 + "/orders/{orderId}/getOrder")
      Call&lt;Order&gt; getOrder(@Path("orderId") String orderId,
                           @Query("key") String apiKey
      //I'm aware this is bad practice ^^, already spoke with server dev
      );
  
  }
  </code></pre>
  
  <p>The Actual outbound call I am making is this:</p>
  
  <pre><code>    public static Order getSingleOrder(String orderId, String apiKey) {
  
          Call&lt;Order&gt; call = myService.getOrder(orderId, apiKey);
  
          Order toReturn = null;
  
          try {
              Response response = call.execute();
              toReturn = (Order) response.body();
          } catch (IOException ioe){
              ioe.printStackTrace();
          }
          return toReturn;
  }
  </code></pre>
  
  <p>While all of this worked just fine in the past, it is no longer working now with the updated libraries. The issue is that it is "ignoring" the path so that instead of sending this call:</p>
  
  <p>GET REQUEST: <a href="http://api.myapiurl.com/orders/12345/getOrder?key=54321" rel="nofollow noreferrer">http://api.myapiurl.com/orders/12345/getOrder?key=54321</a></p>
  
  <p>It is now making this request:</p>
  
  <p>GET REQUEST: <a href="http://api.myapiurl.com/" rel="nofollow noreferrer">http://api.myapiurl.com/</a></p>
  
  <p>and that's it. Anything after the .com in the api base string is never getting sent. I am reading through my logcat and the subsequent OkHttp logging statements to see where the call is failing:  </p>
  
  <p>Sample:</p>
  
  <pre><code>--&gt; GET http://api.myapiurl.com/ http/1.1
  --&gt; END GET
  </code></pre>
  
  <p>Does anyone have any idea why this is happening when it worked fine before I updated?</p>
  
  <p>Thanks for the help all!</p>