Open
Description
I'm getting HTTP 500 response for the batch userDeletion request. I tried submitting a single request without batching and it worked, so the issue seems to be with the batching.
Below is the snippet to reproduce the issue.
import googleapiclient.discovery
from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/analytics.user.deletion']
SERVICE_ACCOUNT_FILE = 'path_to_key_file.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE,
scopes=SCOPES
)
analytics_client = googleapiclient.discovery.build(
'analytics',
'v3',
credentials=credentials
)
data = {"kind": "analytics#userDeletionRequest", "id": {"type": "CLIENT_ID", "userId": "11232.122"}, "webPropertyId": "UA-prodp1"}
batch = analytics_client.new_batch_http_request()
user_deletion_request_resource = analytics_client.userDeletion().userDeletionRequest()
batch.add(user_deletion_request_resource.upsert(body=data), request_id='req-1')
resp = batch.execute()
This throws an exception with HttpError 500.
File "services/gapi_batch_test.py", line 31, in <module>
resp = batch.execute()
File "/Users/XYZ/venv/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/XYZ/venv/lib/python3.8/site-packages/googleapiclient/http.py", line 1560, in execute
self._execute(http, self._order, self._requests)
File "/Users/XYZ/venv/lib/python3.8/site-packages/googleapiclient/http.py", line 1494, in _execute
raise HttpError(resp, content, uri=self._batch_uri)
googleapiclient.errors.HttpError: <HttpError 500 when requesting https://analytics.googleapis.com/batch/analytics/v3 returned "">
Packages
google-api-core==1.27.0
google-api-python-client==2.4.0
google-auth==1.30.0
google-auth-httplib2==0.1.0
Python 3.8.2