Search code examples
pythongmail-apigoogle-api-python-client

gmail python client api import message shows Syntax error


gmail python api service.users().messages().import shows Syntax error here is line of code

mgg = services.users().messages().import(userId='me', raw=base64.urlsafe_b64encode(mime_msg.as_string()), labelIds=mime_msg.get('labelIds')).execute()

error is showing at bracket of import(

If I change import to something such as importee then it is showing this error AttributeError: 'Resource' object has no attribute 'importee' So looks like it is related to?

Python Reserved Keyword

I have also submitted bug in gmail api here is link to google issue tracker


Solution

  • I found a comment by user cdleary that helped. Work-around is I appended _ to import. service.users().messages().import_() is working. Though still I have issue open in Google issue tracker.