title: Apparent character limit for files.list search string in Google Drive API
body: <p>I am using Python to access my Google Drive account via the Google Drive API. I would like to list only those files whose names start with a certain long character string. To do this, I am using the <code>files.list</code> <code>contains</code> clause, as described in <a href="https://developers.google.com/drive/v3/web/search-parameters" rel="nofollow noreferrer">this documentation</a>. I have discovered that this approach does not work as expected when the search string exceeds 26 characters.</p>
  
  <p>To replicate, do the following:</p>
  
  <ol>
  <li><p>Set up a Google Drive service account.</p></li>
  <li><p>Create a folder in your Google Drive account and give the service account access.</p></li>
  <li><p>Upload two empty files to this folder, one named <code>abcdefghijklmnopqrstuvwxyz1</code> and another named <code>abcdefghijklmnopqrstuvwxyza1</code>.</p></li>
  <li><p>Use the API to list the files in the folder, first matching on files that contain <code>abcdefghijklmnopqrstuvwxyz</code> and then on files that contain <code>abcdefghijklmnopqrstuvwxyza</code>. The first search expectedly returns both files, however the second search should return the second file but instead returns none.</p></li>
  </ol>
  
  <p>Here is the Python code I used to test:</p>
  
  <pre><code>import httplib2
  from oauth2client.service_account import ServiceAccountCredentials
  from apiclient import discovery
  
  SCOPES = 'https://www.googleapis.com/auth/drive'
  CLIENT_SECRET_FILE = 'client_secret.json'
  
  credentials = ServiceAccountCredentials.from_json_keyfile_name(CLIENT_SECRET_FILE, SCOPES)
  http = credentials.authorize(httplib2.Http())
  service = discovery.build('drive', 'v3', http=http)
  folder = '1mkebcpZ-mIhq4dLWwePqHqwzw6kUAj1-'
  
  prefix = 'abcdefghijklmnopqrstuvwxyz'
  
  results = service.files().list(
      fields="files(id, name)",
      q="'%s' in parents and name contains '%s'" % (folder, prefix)
  ).execute()
  
  print('First result:')
  print(results['files'])
  
  prefix = 'abcdefghijklmnopqrstuvwxyza'
  
  results = service.files().list(
      fields="files(id, name)",
      q="'%s' in parents and name contains '%s'" % (folder, prefix)
  ).execute()
  
  print('Second result:')
  print(results['files'])
  </code></pre>
  
  <p>Here is my output:</p>
  
  <pre><code>First result:
  [{u'id': u'1Wwzym1ZVMTWzuX-K0eT0-xJrWI8t_YGN', u'name': u'abcdefghijklmnopqrstuvwxyza1'}, {u'id': u'16i4SSwYSbhV9hCFUaCwE7nrYdxBntIi_', u'name': u'abcdefghijklmnopqrstuvwxyz1'}]
  Second result:
  []
  </code></pre>
  
  <p>Why doesn't the file <code>abcdefghijklmnopqrstuvwxyza1</code> appear in the second result?</p>