title: Google Sheet API inserting Multiple Rows Android
body: <p>I am trying to insert multiple Values in my Google Sheet Through API but it is giving me error, the error is listed below </p>
  
  <pre><code>{
    "code" : 400,
    "errors" : [ {
      "domain" : "global",
      "message" : "Invalid values[1][0]: list_value {\n  values {\n    string_value: \"1041\"\n  }\n  values {\n    string_value: \"28.4121001\"\n  }\n  values {\n    string_value: \"77.0438644\"\n  }\n  values {\n    string_value: \"2156-5091\"\n  }\n  values {\n    string_value: \"ABCD\"\n  }\n  values {\n    string_value: \"Sep 20 2017, 01:27 PM\"\n  }\n  values {\n    string_value: \"NA\"\n  }\n  values {\n    string_value: \"A1E85C43-B8C8-42F0-96EC-D1586FCBB2CF\"\n  }\n}\n",
      "reason" : "badRequest"
    } ],
    "message" : "Invalid values[1][0]: list_value {\n  values {\n    string_value: \"1041\"\n  }\n  values {\n    string_value: \"28.4121001\"\n  }\n  values {\n    string_value: \"77.0438644\"\n  }\n  values {\n    string_value: \"2156-5091\"\n  }\n  values {\n    string_value: \"ABCD\"\n  }\n  values {\n    string_value: \"Sep 20 2017, 01:27 PM\"\n  }\n  values {\n    string_value: \"NA\"\n  }\n  values {\n    string_value: \"A1E85C43-B8C8-42F0-96EC-D1586FCBB2CF\"\n  }\n}\n",
    "status" : "INVALID_ARGUMENT"
  }
  </code></pre>
  
  <p>Below is the code I am using to send the data to the sheet </p>
  
  <pre><code>      private class MakeRequestTask extends AsyncTask&lt;Void, Void, AppendValuesResponse&gt; {
          private com.google.api.services.sheets.v4.Sheets mService = null;
          private Exception mLastError = null;
          List&lt;CustomerGeoData&gt; mList;
  
          MakeRequestTask(GoogleAccountCredential credential, List&lt;CustomerGeoData&gt; mList) {
              HttpTransport transport = AndroidHttp.newCompatibleTransport();
              JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
              mService = new com.google.api.services.sheets.v4.Sheets.Builder(
                      transport, jsonFactory, credential)
                      .setApplicationName("Geo Tagger")
                      .build();
  
              this.mList = mList;
          }
  
          /**
           * Background task to call Google Sheets API.
           *
           * @param params no parameters needed for this task.
           */
          @Override
          protected AppendValuesResponse doInBackground(Void... params) {
              try {
                  return getDataFromApi();
              } catch (Exception e) {
                  e.printStackTrace();
                  mLastError = e;
                  cancel(true);
                  return null;
              }
          }
  
          /**
           * Sending the data to the Sheet
           * https://docs.google.com/spreadsheets/d/1qLwONBo8SbjvVwEi_RCjzw8D8teHcdke-rkCEowq2bU/edit
           *
           * @return List of names and majors
           * @throws IOException
           */
          private AppendValuesResponse getDataFromApi() throws IOException {
              String spreadsheetId = GeoTaggerConstants.CUSTOMER_GEO_DATA;
              String range = GeoTaggerConstants.CUSTOMER_GEO_DATA_SHEET_NAME + "!A1:H";
  
              Object[] additionalRows = new Object[mList.size()];
              Object[] cellValue;
  
              List&lt;List&lt;Object&gt;&gt; values = new ArrayList&lt;&gt;();
  
              for (int i = 0; i &lt; mList.size(); i++) {
                  //Cell Values
                  cellValue = new String[]{mList.get(i).getCustomer_Barcode(), mList.get(i).getLatitude(), mList.get(i).getLongitude(),
                          mList.get(i).getCustomer_No(), mList.get(i).getCustomer_Name(), mList.get(i).getLogged_At(),
                          mList.get(i).getLogged_By(), mList.get(i).getRow_ID()};
  
                  //Additional Rows added here till the size of the list
                  additionalRows[i] = Arrays.asList(cellValue);
  
                  lastCustomerName = mList.get(i).getCustomer_Name();
              }
              values.add(Arrays.asList(additionalRows));    
              ValueRange body = new ValueRange().setValues(values);
  
              AppendValuesResponse result =
                      mService.spreadsheets().values().append(spreadsheetId, range, body)
                              .setValueInputOption("RAW")
                              .execute();
  
  
              return result;
          }
  
  
          @Override
          protected void onPreExecute() {
              //Start Loading
          }
  
          @Override
          protected void onPostExecute(AppendValuesResponse output) {
              if (output == null || output.size() == 0) {
                  System.out.println("No results returned.");
              } else {
  
                  System.out.println("output  &gt;&gt;&gt;  " + output);
              }
          }
  
          @Override
          protected void onCancelled() {
              if (mLastError != null) {
                  if (mLastError instanceof GooglePlayServicesAvailabilityIOException) {
                      showGooglePlayServicesAvailabilityErrorDialog(
                              ((GooglePlayServicesAvailabilityIOException) mLastError)
                                      .getConnectionStatusCode());
                  } else if (mLastError instanceof UserRecoverableAuthIOException) {
                      startActivityForResult(
                              ((UserRecoverableAuthIOException) mLastError).getIntent(), REQUEST_AUTHORIZATION);
                  } else {
                      System.out.println("The following error occurred:\n"
                              + mLastError.getCause());
                  }
              } else {
                  System.out.println("Request cancelled.");
              }
          }
      }
  </code></pre>
  
  <p>This is what my <code>mList</code> looks like the data I am sending to the Sheet API</p>
  
  <p><img src="https://i.stack.imgur.com/eU4wU.png" alt="Values sending looks like this"></p>
  
  <p>Any help is appreciable, Thanks in Advance</p>