library version: 4.12.1
we are creating and sending drafts per the documentation here: https://developer.nylas.com/docs/api/#post/send and noticed that the from field in the request is not populated in this case (defaults to null). Setting as 'from' via kwargs works fine. This is visible both in the as_json method and the urllib request logs.
not working example:
>>> draft = client.drafts.create()
>>> draft.from_ = [{'email': 'from@example.com', 'name': 'Sender (Test)'}]
>>> draft.to = [{'name': 'Recipient', 'email': 'to@example.com'}]
>>> draft.subject = 'test'
>>> draft.body = 'testing'
>>> draft.as_json()
{'bcc': None, 'cc': None, 'body': 'testing', 'date': None, 'files': None, 'from': None, 'id': None, 'account_id': None, 'object': None, 'subject': 'test', 'thread_id': None, 'to': [{'name': 'Recipient', 'email': 'to@example.com'}], 'unread': None, 'version': None, 'file_ids': [], 'reply_to_message_id': None, 'reply_to': None, 'starred': None, 'snippet': None, 'tracking': None}
>>> draft.send()
...snipped...
send: b'{"bcc": null, "cc": null, "body": "testing", "date": null, "files": null, "from": null, "id": null, "account_id": null, "object": null, "subject": "test", "thread_id": null, "to": [{"name": "Recipient", "email": "to@example.com"}], "unread": null, "version": null, "file_ids": [], "reply_to_message_id": null, "reply_to": null, "starred": null, "snippet": null, "tracking": null}'
...snipped...
{'account_id': 'xxxx', 'bcc': [], 'body': 'testing', 'cc': [], 'date': 123123123, 'events': [], 'files': [], 'from': [{'email': 'from@example.com', 'name': 'name attached to account'}], 'id': 'xxxx', 'labels': [], 'object': 'message', 'reply_to': [], 'snippet': 'testing', 'starred': False, 'subject': 'test', 'thread_id': 'xxxx', 'to': [{'email': 'to@example.com', 'name': 'Recipient'}], 'unread': False}
working example:
>>> draft = client.drafts.create(**{'from': [{'email': 'from@example.com', 'name': 'Sender (test)'}], 'to': [{'email': 'to@example.com'}], 'subject': 'test', 'body': 'test2'})
>>> draft.as_json()
{'bcc': None, 'cc': None, 'body': 'test2', 'date': None, 'files': None, 'from': [{'email': 'from@example.com', 'name': 'Sender (test)'}], 'id': None, 'account_id': None, 'object': None, 'subject': 'test', 'thread_id': None, 'to': [{'email': 'to@example.com'}], 'unread': None, 'version': None, 'file_ids': [], 'reply_to_message_id': None, 'reply_to': None, 'starred': None, 'snippet': None, 'tracking': None}
>>> draft.send()
...snipped request log...
send: b'{"bcc": null, "cc": null, "body": "test2", "date": null, "files": null, "from": [{"email": "from@example.com", "name": "Sender (test)"}], "id": null, "account_id": null, "object": null, "subject": "test", "thread_id": null, "to": [{"email": "to@example.com"}], "unread": null, "version": null, "file_ids": [], "reply_to_message_id": null, "reply_to": null, "starred": null, "snippet": null, "tracking": null}'
...snipped request log...
{'account_id': 'xxxx', 'bcc': [], 'body': 'test2', 'cc': [], 'date': 123123123, 'events': [], 'files': [], 'from': [{'email': 'from@example.com', 'name': 'Sender (test)'}], 'id': 'xxxx', 'labels': [], 'object': 'message', 'reply_to': [], 'snippet': 'test2', 'starred': False, 'subject': 'test', 'thread_id': 'xxxx', 'to': [{'email': 'to@example.com', 'name': ''}], 'unread': False}
library version: 4.12.1
we are creating and sending drafts per the documentation here: https://developer.nylas.com/docs/api/#post/send and noticed that the from field in the request is not populated in this case (defaults to null). Setting as 'from' via kwargs works fine. This is visible both in the
as_jsonmethod and the urllib request logs.not working example:
working example: