Why do I get 'invalid_request_error' when sending emails with attachments?

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

  1. Use ASCII-only filenames.
    Rename attachments so they contain only standard characters (A–Z, a–z, 0–9, hyphens, underscores).
  2. Explicitly set the MIME type.
    Always include a valid content_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

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.