title: How do I solve “AttributeError: 'Resource' object has no attribute 'documents'” error?
body: <p>I am working on this last 3 days. i don't have any idea.. there are similar question but i didn't got my answer.</p>
  <p>this is ERROR</p>
  <blockquote>
  <p>File ID: 1U4XUrAhMk1WFAKE_IDqmQcteYqmIWPMFEd Traceback (most recent</p>
  </blockquote>
  <p>File is Created I want to USE this ID and Edit Docs in Drive</p>
  <blockquote>
  <p>call last):   File &quot;main.py&quot;, line 61, in </p>
  </blockquote>
  <blockquote>
  <pre><code>main()   File &quot;main.py&quot;, line 53, in main
  </code></pre>
  </blockquote>
  <blockquote>
  <pre><code>service.documents() AttributeError: 'Resource' object has no attribute 'documents'
  </code></pre>
  </blockquote>
  <p>My goal</p>
  <ol>
  <li><p>create Docs in GOOGLE Drive</p>
  </li>
  <li><p>insert Table in it</p>
  </li>
  </ol>
  <pre><code>from __future__ import print_function
  import pickle
  import os.path
  from googleapiclient.discovery import build
  from google_auth_oauthlib.flow import InstalledAppFlow
  from google.auth.transport.requests import Request
  import sys
  from gdoctableapppy import gdoctableapp
  
  # If modifying these scopes, delete the file token.pickle.
  SCOPES = [&quot;https://www.googleapis.com/auth/drive&quot;]
  
  
  def main():
      &quot;&quot;&quot;Shows basic usage of the Drive v3 API.
      Prints the names and ids of the first 10 files the user has access to.
      &quot;&quot;&quot;
      creds = None
      # The file token.pickle stores the user's access and refresh tokens, and is
      # created automatically when the authorization flow completes for the first
      # time.
      if os.path.exists(&quot;token.pickle&quot;):
          with open(&quot;token.pickle&quot;, &quot;rb&quot;) as token:
              creds = pickle.load(token)
      # If there are no (valid) credentials available, let the user log in.
      if not creds or not creds.valid:
          if creds and creds.expired and creds.refresh_token:
              creds.refresh(Request())
          else:
              flow = InstalledAppFlow.from_client_secrets_file(&quot;credentials.json&quot;, SCOPES)
              creds = flow.run_local_server(port=0)
          # Save the credentials for the next run
          with open(&quot;token.pickle&quot;, &quot;wb&quot;) as token:
              pickle.dump(creds, token)
  
      service = build(&quot;drive&quot;, &quot;v3&quot;, credentials=creds)
      serviceDoc = build(&quot;docs&quot;, &quot;v1&quot;, credentials=creds)
      # Call the Drive v3 API
      # Create Google Docs file in folder
  
      file_metadata = {
          &quot;name&quot;: sys.argv[1],
          &quot;parents&quot;: [&quot;Folder ID&quot;],
      }
      file = service.files().create(body=file_metadata, fields=&quot;id&quot;).execute()
      print(&quot;File ID: %s&quot; % file.get(&quot;id&quot;))
  
      DOCUMENT_ID = file.get(&quot;id&quot;)
  
      requests = [{&quot;insertTable&quot;: {&quot;rows&quot;: 2, &quot;columns&quot;: 2, &quot;location&quot;: {&quot;index&quot;: 1}}}]
  
      result = (
          service.documents()
          .batchUpdate(documentId=DOCUMENT_ID, body={&quot;requests&quot;: requests})
          .execute()
      )
      return
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>