title: GET request with parameters using Retrofit
body: <p>I am learning Retrofit. I've built an API using PHP Slim to check whether an email given by user exist or not in my database. My API is okay. I've tested it via Postman. But when I'm calling my API it's not giving correct result.</p>
  
  <p><strong>Api.java</strong></p>
  
  <pre><code>package com.example.royta.retrofitdemo.APIs;
  
  
  import com.example.royta.retrofitdemo.ModelClass.UserExist;
  import retrofit2.Call;
  import retrofit2.http.Body;
  import retrofit2.http.Field;
  import retrofit2.http.FormUrlEncoded;
  import retrofit2.http.GET;
  import retrofit2.http.POST;
  import retrofit2.http.PUT;
  import retrofit2.http.Path;
  import retrofit2.http.Query;
  
  public interface Api {
  
      @GET("finduser")
      Call&lt;UserExist&gt; isUserExist(
              @Query("email") String email
      );
  
  }
  </code></pre>
  
  <p><strong>Please check the Screenshot for JSON response.</strong></p>
  
  <p><strong>UserExist.java</strong></p>
  
  <pre><code>package com.example.royta.retrofitdemo.ModelClass;
  
  import com.google.gson.annotations.SerializedName;
  
  public class UserExist {
      @SerializedName("email")
      private boolean email;
  
      public UserExist(boolean email) {
          this.email = email;
      }
  
      public boolean isEmailExist() {
          return email;
      }
  }
  </code></pre>
  
  <p><strong>RetrofitClient.java</strong></p>
  
  <pre><code>package com.example.royta.retrofitdemo.APIs;
  
  import retrofit2.Retrofit;
  import retrofit2.converter.gson.GsonConverterFactory;
  
  public class RetrofitClient {
      private static final String BASE_URL = "http://24d00bb3.ngrok.io/MyApi/public/";
      private static RetrofitClient retrofitClient;
      private Retrofit retrofit;
  
      private RetrofitClient() {
          retrofit = new Retrofit.Builder()
                  .baseUrl(BASE_URL)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
      }
  
      public static synchronized RetrofitClient getInstance() {
          if(retrofitClient == null) {
              retrofitClient = new RetrofitClient();
          }
          return retrofitClient;
      }
  
      public Api getApi() {
          return retrofit.create(Api.class);
      }
  }
  </code></pre>
  
  <p>Here is the call</p>
  
  <p><strong>FindAccount.java</strong></p>
  
  <pre><code>Call &lt;UserExist&gt; call = RetrofitClient.getInstance().getApi().isUserExist("troy@yahoo.com");
  
          call.enqueue(new Callback&lt;UserExist&gt;() {
              @Override
              public void onResponse(Call&lt;UserExist&gt; call, Response&lt;UserExist&gt; response) {
  
                  if(response.body().isEmailExist()) {
                      //send code in email;
                      Toast.makeText(FindAccount.this, "Send code in email", Toast.LENGTH_SHORT).show();
                  }
                  else {
                      Toast.makeText(FindAccount.this, "You are not registered", Toast.LENGTH_SHORT).show();
                  }
              }
  
              @Override
              public void onFailure(Call&lt;UserExist&gt; call, Throwable t) {
                  Log.d("ROYs", "onFailure block");
              }
          });
  </code></pre>
  
  <p>the email "troy@yahoo.com" is exist in my database.But the following call giving me false result. It should be true.</p>
  
  <pre><code>response.body().isEmailExist()
  </code></pre>
  
  <p><strong>Screenshot is the proof of my API. Please Help. Thanks in advance.</strong>
  <a href="https://i.stack.imgur.com/B5zwA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B5zwA.jpg" alt="enter image description here"></a></p>