Closed Arbitrage0 closed 4 years ago
Hi Elmer, thanks for having a look. As I mentioned, getting the request body in JSON using implementation 1 doesn't work because it yields the same error (i.e. FileName and FileType are not JSON serializable). Using implementation 2, the request body is missing the attachment content, type and filename even though I've declared them:
{
"attachments": [
{
"content_id": "File",
"disposition": "attachment"
}
],
"content": [
{
"type": "text/html",
"value": "<strong>Some content</strong>"
}
],
"from": {
"email": "test@example.com",
"name": "Example"
},
"personalizations": [
{
"bcc": [
{
"email": "yetanother@example.com"
}
],
"to": [
{
"email": "another@example.com"
}
]
}
],
"subject": "Subject"
}
For implementation 1, the param order to init the Attachment
is incorrect (FileName
and FileType
are swapped).
def __init__(
self,
file_content=None,
file_name=None,
file_type=None,
disposition=None,
content_id=None):
For implementation 2, the property names are incorrect. Should be:
attachment.file_content = encoded
attachment.file_type = "application/pdf"
attachment.file_name = "file.pdf"
It works now thanks, but you should know that the full example in the Quickstart (which I based my code on) does neither of those things and is therefore incredibly unhelpful. (see Implementation 1, Implementation 2).
Ah, I see. Thanks for the PR!
Issue Summary
I'm trying to send an email with an attachment, but I get errors saying that (depending on the implementation) either the FileName is not JSON serializable (implementation 1), or that the file content and file name are missing, even though they are not (implementation 2).
Steps to Reproduce
Code Snippet
Exception/Log
Technical details: