I have a cloud function on GCP which runs for more than 18 months. Suddenly a week ago it stopped working.
The code
import googleapiclient.discovery
adminDirectoryService = googleapiclient.discovery.build('admin', 'directory_v1', credentials = gsuiteCredentials, cache_discovery=False)
result = adminDirectoryService.users().watch(body=watchBody, projection=projection, event=eventType, maxResults=1, customer=gSuiteCutomerId, viewType=viewType).execute()
The exception:
result = adminDirectoryService.users().watch(body=watchBody, projection=projection, event=eventType, maxResults=1, customer=gSuiteCutomerId, viewType=viewType).execute()
File "/env/lib/python3.7/site-packages/google_api_python_client-1.7.8-py3.7.egg/googleapiclient/discovery.py", line 723, in method
raise TypeError('Got an unexpected keyword argument "%s"' % name)
TypeError: Got an unexpected keyword argument "projection"
I have no idea what is causing the issue. I have checked the documentation and it clearly states the projection
argument exists.
Does anyone else encounter the issue? Any suggestions?
The following have fixed my issue: I have removed the projection, maxResults, and viewType arguments from my request, and all worked fine.
Some explanation of why the issue happened. The googleapiclient.discovery builds the API based on JSON provided to it. Seems like Google changed the returned JSON without saying those braking changes to anyone.
The JSON can be found here (for admin, directory_v1)
If anyone is using a different version or API. I have found the source by looking at the discovery code here.
I hope it will help anyone else.
EDIT
It seems the issue was fixed by Google. The workaround solution in this answer is not needed anymore