Home » Android » Android app Not Submitting Google Docs form

Android app Not Submitting Google Docs form

Posted by: admin November 1, 2017 Leave a comment


App needs to Submit Google Docs form. used OKhttp libraries to achieve the functionality. Created separate classes to call Okhttps objects for submit the google docs form. Calling this class methods in the Android Main activity. Code is running without any exceptions But google form is not submitting. In a debug mode “Response” body is captured the Message “Something went wrong” Please try again. Internet permissions was given in the App manifest file. Also Permissions given like Google form can submit by anonymous users. Unable to find the issue. Any solution to fix it or any other way to submit google form

Here is the code.

public class HttpRequest extends AsyncTask < String, Void, Boolean > {

  private OkHttpClient okHttpClient;
  public static final MediaType FORM_DATA_TYPE = MediaType.parse("application/x-www-form-urlencoded; charset=utf-8");
  public static final String URL = "https://docs.google.com/forms/d/e/1FAIpQLSeZe3KzDyl_C3GZRwOb0-0TeRMNV9p6INzr04MzHyyuR_e/formResponse";
  //URL Input Elelemt IDs
  public static final String BLOCKNUMBER_KEY = "entry_129841939";
  public static final String HOUSENUMBER_KEY = "entry_1387986307";
  public static final String OWNERNAME_KEY = "entry_620139325";
  public static final String OWNEREMAIL_KEY = "entry_1278237615";
  public static int responseCode = 0;

  //private final Context context;

  public HttpRequest() {
   //context = this;


  protected Boolean doInBackground(String...params) {

   String blockNumber = params[2];
   String houseNumber = params[3];
   String ownerName = params[4];
   Boolean result = true;

   try {
    OkHttpClient client = new OkHttpClient();
    FormBody body = new FormBody.Builder()
     .add(BLOCKNUMBER_KEY, blockNumber)
     .add(HOUSENUMBER_KEY, houseNumber)
     .add(OWNERNAME_KEY, ownerName)
     .add(OWNEREMAIL_KEY, ownerEmail)
    Request request = new Request.Builder()
    responseCode = 0;
    Response response = client.newCall(request).execute();

    if ((responseCode = response.code()) == 200) {
     String jasonData = response.body().string();
     String Htmlvalue = jasonData.toString();
     JSONObject json = new JSONObject(jasonData);

     String token = json.getString("token");
   } catch (Exception ex) {
   return null;