我尝试在Django中使用gmail send API更改发件人。
在文档中,为了更改“ Users.settings.sendAs:更新”,我可以与其他发件人发送电子邮件,并且需要获取两个参数(userId和sendAsEmail)
service_user = service.users().settings().sendAs()
service_user.patch(userId='me',sendAsEmail='example@gmail.com').execute()
但是,它要求我输入参数“ body”,我应该在这里输入什么?
Traceback (most recent call last):
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/rest_framework/views.py", line 483, in dispatch
response = self.handle_exception(exc)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/rest_framework/views.py", line 443, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/rest_framework/views.py", line 480, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/work/account/views/user/user/reset_password.py", line 58, in patch
service = service_account_login(EMAIL_FROM)
File "/Users/work/account/utils/send_email_by_gmail.py", line 148, in service_account_login
service_user.patch(userId='me', sendAsEmail='example@gmail.com').execute()
File "/usr/local/var/pyenv/versions/alms-back/lib/python3.6/site-packages/googleapiclient/discovery.py", line 737, in method
raise TypeError('Missing required parameter "%s"' % name)
TypeError: Missing required parameter "body"
[19/Mar/2019 16:16:46] "PATCH /account/reset-password/ HTTP/1.1" 500 19583
pydev debugger: process 5403 is connecting