Sending Email Attachments via the Nylas API
When sending emails with attachments through the Nylas API, you may see an invalid_request_error
if:
- Attachment filenames contain non-ASCII characters (e.g., ü, é).
- The
content_type
field is missing or empty.
Error Response Example
{
"request_id": "3498850571-af3b363c-8f87-XYZ",
"error": {
"type": "invalid_request_error",
"message": "field 'content_type' should not be empty"
}
}
Root Cause
Some email providers—most notably Google—cannot infer the MIME type when a filename includes non-ASCII characters. In these cases, Nylas receives no content_type
from the provider and returns it as empty, triggering the error.
Resolution Steps
-
Use ASCII-only filenames.
Rename attachments so they contain only standard characters (A–Z, a–z, 0–9, hyphens, underscores). -
Explicitly set the MIME type.
Always include a validcontent_type
for each attachment in your request.
Correct Attachment Payload
{
"attachments": [
{
"filename": "overview.txt",
"content": "VGVzdCBmaWxl",
"content_type": "text/plain"
}
]
}
For full details, refer to the API documentation on sending messages with attachments .
Updated
Comments
0 comments
Please sign in to leave a comment.