Attach a complete email as file to a task

Using Google Apps Script I want to upload and attach an email via the API to an Asana task. I am using the /tasks/{taskId}/attachments API. I use a filename with a .eml extension.

It does not matter which content type I set (I’ve tried none at all, message/rfc822 and application/octet-stream), it does not work.

I always get an HTTP 400 error with the message “File is not an object”.

I have no problem attaching PDFs.

I can upload eml files to a task using the GUI (it uses content_type message/rfc822) so I hope it’s possible with the API.

Do I need to encode the eml file in any particular way, or maybe add some special header?

Any tips gratefully accepted.

Pete