google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

drive.About documentation wrong/missing

Open FirefighterBlu3 opened this issue 3 years ago • 1 comments

Environment details

  • OS type and version:
    • Arch Linux
  • Python version: python --version
    • 3.10.1
  • pip version: pip --version
    • 22.0.4
  • google-api-python-client version: pip show google-api-python-client
    • 2.42.0

Steps to reproduce

  1. .# setup creds (a service account)
  2. service = build('drive', 'v3', credentials=creds)
  3. service.about().get().execute()

Code example

# setup creds (a service account)
service = build('drive', 'v3', credentials=creds)
service.about().get().execute()

Stack trace

  File "/home/david/Desktop/Projects/indeed/gdrive-revisions/gdrive_revisions.py", line 36, in get_drive
    data = service.about().get().execute()
  File "/usr/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/googleapiclient/http.py", line 937, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/drive/v3/about?alt=json returned "The 'fields' parameter is required for this method.". Details: "[{'message': "The 'fields' parameter is required for this method.", 'domain': 'global', 'reason': 'required', 'location': 'fields', 'locationType': 'parameter'}]">

The docstring for this method indicates there are no explicit calling arguments:

method(**kwargs) method of googleapiclient.discovery.Resource instance
    Gets information about the user, the user's Drive, and system capabilities.
    
    Args:
    ...

Additionally, the documentation at https://developers.google.com/resources/api-libraries/documentation/drive/v3/python/latest/drive_v3.about.html also indicates there are no consumed arguments

FirefighterBlu3 avatar Apr 01 '22 22:04 FirefighterBlu3

Hi @FirefighterBlu3,

Thanks for reporting an issue with the docs. I can confirm that the fields parameter is needed for service.about().get(). I'll keep this issue open until the docs are fixed.

The following code worked to get information about the current user:

service.about().get(fields="user").execute()

You can also use * during development to get all fields as described here. For example,

service.about().get(fields="*").execute()

You'll achieve greater performance by only selecting the fields you need.

parthea avatar Apr 04 '22 18:04 parthea