-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The content_id parameter is required if disposition = \'inline\'.' #841
Comments
Hello @dungahk, It looks like there is a bug in the With Best Regards, Elmer |
Hi @thinkingserious , Best regards, |
Yeah, looks like just a simple typescript error. A simple cast of your object to any is a quick and simple fix until the fix is roled out. mail.attachments.push({
content: logo,
content_id: 'logo',
filename: 'logo.png',
disposition: 'inline',
type: 'image/png',
} as any); |
So the TS definition is correct, but the underlying |
Ah okay. So it looks like there are two classes: AttachmentData and AttachmentJSON Instead of casting to any like I suggested above you can cast to Using MailData in send is problematic and can be confusing because if you define it without using |
I meant that the underlying JS that adds the attachment to the But I don't have a strong opinion on which way to go here. |
Ah yes that would work considering the mail service already generates a Mail object if it isn't that class already. That object then calls setAttachments, setPersonalizations, etc. This would need to be done on most other classes as well. I'll see if I have time to submit a PR 🤩. |
Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you! |
Any updates on this issue? Typescript keeps bothering when using "content_id" |
Issue Summary
Error when trying to send an email with an attachment.
The content_id parameter is required if disposition = \'inline\'.',
Steps to Reproduce
Just try to send an email with attachments and disposition 'inline'.
My code:
I'm using Typescript and the attachments property is defined as an Array of AttachmentData, which includes a property called
contentId
, but the API requires the propertycontent_id
which is in the interface AttachmentJSON instead.send function types: https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/mail/src/mail.d.ts#L20
attachments property types: https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/helpers/classes/mail.d.ts#L134
AttachmentData interface types: https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/helpers/classes/attachment.d.ts#L1
Technical details:
The text was updated successfully, but these errors were encountered: