title: Getting improper response for Json webservice
body: <p>I am using okhttp library for Json parsing.</p>
  
  <p>I have created my AsyncTask as below for my Login Webservice : </p>
  
  <pre><code>class LoginAsyncTask extends AsyncTask&lt;Void, Void, Void&gt; {
      private ProgressDialog dialog;
      private String mstrLoginResponse="";
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          try {
              dialog = new ProgressDialog(SignInActivity.this);
              dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
              dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
              dialog.setCancelable(false);
              if (!dialog.isShowing()) {
                  dialog.show();
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
  
      }
  
      @Override
      protected Void doInBackground(Void... params) {
          try {
              RequestBody formBody = new FormEncodingBuilder()
                      .add("mobile_number", strPhone)
                      .add("password", strPassword)
                      .build();
              mstrLoginResponse = HttpUtils.postRun("login", formBody);
              Constant.displayLogE("&gt;&gt;&gt;TT : ",""+mstrLoginResponse);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(Void aVoid) {
          super.onPostExecute(aVoid);
          if (dialog.isShowing()) {
              dialog.dismiss();
          }
          if (mstrLoginResponse != null) {
              try {
                  JSONObject jsonRegister = new JSONObject(mstrLoginResponse);
  
                  int strLoginStatus = jsonRegister.getInt("status");
                  String strMessage = jsonRegister.getString("message");
                  if (strLoginStatus == 1) {
                      JSONObject jsonUserId = jsonRegister.getJSONObject("data");
                      String strUserId = jsonUserId.getString("user_id");
                      AppSettings.setPref(SignInActivity.this, USER_ID, String.valueOf(strUserId));
                      startActivity(new Intent(SignInActivity.this, MainActivity.class));
                      finish();
                      Constant.displayToast(SignInActivity.this, "" + strMessage);
                  } else {
                      ApiUtils.showAlertDialogue(SignInActivity.this, "" + strMessage);
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>But, Unfortunetly getting below response : </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
                                                   &lt;html lang="en"&gt;
                                                   &lt;head&gt;
                                                   &lt;meta charset="utf-8"&gt;
                                                   &lt;title&gt;404 Page Not Found&lt;/title&gt;
                                                   &lt;style type="text/css"&gt;
  
                                                   ::selection { background-color: #E13300; color: white; }
                                                   ::-moz-selection { background-color: #E13300; color: white; }
  </code></pre>
  
  <p>and Exeption : <code>org.json.JSONException: Value &lt;!DOCTYPE of type java.lang.String cannot be converted to JSONObject
  06-24 00:41:03.314 349-349/com.roadysmart W/System.err:     at org.json.JSON.typeMismatch(JSON.java:111)</code></p>
  
  <p>I am getting proper response in Postman. 
  My HttpUtils class is as below : `</p>
  
  <pre><code>    public class HttpUtils {
      /*public static final MediaType JSON
              = MediaType.parse("application/json; charset=utf-8");*/
    public static String BASE_URL = "http://temp.in/projects/temp/";
  
      public static OkHttpClient client = new OkHttpClient();
  
      public static String getRun(String url) throws IOException {
          Log.d("URL===&gt;", url);
          Request request = new Request.Builder()
                  .url(url)
                  .build();
          Response response = client.newCall(request).execute();
          return response.body().string();
      }
  
      public static String postRun(String type, RequestBody formBody) throws IOException {
          String str = "";
          Request request = new Request.Builder()
                  .url(BASE_URL)
                  .post(formBody)
                  .build();
          Response response = client.newCall(request).execute();
          return response.body().string();
      }
  
  }
  </code></pre>
  
  <p>What might be the mistake ? Please, Help .</p>
  
  <p>===>>EDIT : </p>
  
  <p>Getting Proper response in postman as below : </p>
  
  <pre><code>{
  "status": 1,
  "message": "Login successful",
  "data": {
      "name": "subhu",
      "mobile_number": "7777777777",
      "email": "bhargavmodi777@gmail.com",
      "user_id": "20"
  }
  </code></pre>
  
  <p>}</p>