title: Internal Server Error 500 on files().list() with Drive REST API
body: <p><strong>Update:</strong> This issue appears to have been resolved. See the <a href="https://issuetracker.google.com/issues/36760989" rel="nofollow noreferrer">bug tracker report</a> for details.</p>
  
  <hr>
  
  <p>I am having some difficulty getting a file listing request through the Drive REST API (v3) accomplished without an 
  internal server error (error code 500.) I am trying to use the <code>name</code> and <code>appProperties</code> keys with a call to
  <code>files().list()</code> in the search criteria with <code>name</code> and <code>createdTime</code> for the sort order. (This is "case 1" in 
  the code below.) The syntax I am using is documented <a href="https://developers.google.com/drive/v3/web/search-parameters" rel="nofollow noreferrer">here</a>.</p>
  
  <p>In an attempt to isolate the problem, I have taken the Google Drive API > REST Android Quickstart project
  found <a href="https://developers.google.com/drive/v3/web/quickstart/android" rel="nofollow noreferrer">here</a> and made some modifications to 
  the <code>getDataFromApi</code> method as shown in the code block below.</p>
  
  <p>There are six test cases using various combinations of search criteria and sort order fields. Some queries succeed while
  others fail with server code 500 and one times out. These results are consistent on an emulator running Android 7.0
  with API 24. My issue originated with an earlier release.</p>
  
  <p>I am most interested in getting a solution to case 1 and offer the other cases as my attempt to figure out what was going wrong. I would appreciate any assistance or ideas on what I might be doing wrong or what else may be happening.</p>
  
  <pre><code>         private List&lt;String&gt; getDataFromApi() throws IOException {
              // Get a list of up to 10 files.
              List&lt;String&gt; fileInfo = new ArrayList&lt;String&gt;();
  
  /*          Case 1: Crashes with following error:
               500 Internal Server Error
               {
                "code" : 500,
                "errors" : [ {
                "domain" : "global",
                "message" : "Internal Error",
                "reason" : "internalError"
               }],
                "message" : "Internal Error"
               } */
              String query = "name contains 'Test' and not appProperties has {key='X' and value='Y'}";
              String orderBy = "name, createdTime";
  
  //            Case 2: Succeeds and lists files.
  //            Like case 1, but "createdTime is dropped in sort order.
  //            String query = "name contains 'Test' and not appProperties has {key='X' and value='Y'}";
  //            String orderBy = "name";
  
  //            Case 3: Succeeds and lists files.
  //            Like case 1, but appProperties criteria is dropped.
  //            String query = "name contains 'Test'";
  //            String orderBy = "name, createdTime";
  
  //            Case 4: Times out.
  //            Like case 1, but the name criteria is dropped.
  //            String query = "not appProperties has {key='X' and value='Y'}";
  //            String orderBy = "name, createdTime";
  
  //            Case 5: Errors out like case 1.
  //            Like case 4, but the selection query is inverted.
  //            String query = "appProperties has {key='X' and value='Y'}";
  //            String orderBy = "name, createdTime";
  
  //            Case 6: Succeeds and lists files.
  //            Like case 4, but name is dropped in sort order.
  //            final String query = "not appProperties has {key='X' and value='Y'}";
  //            final String orderBy = "createdTime";
  
              FileList result = mService.files().list()
                      .setPageSize(10)
                      .setFields("nextPageToken, files(id, name)")
                      // following was added
                      .setOrderBy(orderBy)
                      .setQ(query)
                      // end added code
                      .execute();
              List&lt;File&gt; files = result.getFiles();
              if (files != null) {
                  for (File file : files) {
                      fileInfo.add(String.format("%s (%s)\n",
                              file.getName(), file.getId()));
                  }
              }
              return fileInfo;
          }
  </code></pre>