Skip to content
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

'contentId' vs 'content_id' in attachments object #1080

Closed
varunj166 opened this issue Mar 31, 2020 · 1 comment
Closed

'contentId' vs 'content_id' in attachments object #1080

varunj166 opened this issue Mar 31, 2020 · 1 comment
Labels
status: duplicate duplicate issue

Comments

@varunj166
Copy link

Issue Summary

SendGrid will throw an error if you use a 'contentId' property on an attachment object (content, type, disposition, etc.). To make it work, you have to use 'content_id'. This is especially unfortunate because the typescript definition file specifies 'contentId', so I have to override it with 'any'.

I looked at your source code. the attachment.js class looks fine, which means the problem is higher up somewhere, perhaps.

Steps to Reproduce

  1. Send an email with:
sg.send({
  to: ...,
  from: ...,
 subject: ...,
 <etc>,
  attachments: [
    {
      content: ...,
      type: ...,,
      disposition: 'inline',
      <etc>,
      contentId: 'someid'
    }
  ]
})
  1. Receive the SendGrid error: "The content_id parameter is required if disposition = 'inline'."
  2. Re-send the message, except replace 'contentId' with 'content_id'.
  3. Everything works great.

Code Snippet

# paste code here

Exception/Log

{
[0]   "message": "Bad Request",
[0]   "code": 400,
[0]   "response": {
[0]     "headers": {
[0]       "server": "nginx",
[0]       "date": "Tue, 31 Mar 2020 16:46:05 GMT",
[0]       "content-type": "application/json",
[0]       "content-length": "232",
[0]       "connection": "close",
[0]       "access-control-allow-origin": "https://sendgrid.api-docs.io",
[0]       "access-control-allow-methods": "POST",
[0]       "access-control-allow-headers": "Authorization, Content-Type, On-behalf-of, x-sg-elas-acl",
[0]       "access-control-max-age": "600",
[0]       "x-no-cors-reason": "https://sendgrid.com/docs/Classroom/Basics/API/cors.html"
[0]     },
[0]     "body": {
[0]       "errors": [
[0]         {
[0]           "message": "The content_id parameter is required if disposition = 'inline'.",
[0]           "field": "attachments.0.content_id",
[0]           "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.content_id"
[0]         }
[0]       ]
[0]     }
[0]   }
[0] }

Technical details:

  • sendgrid-nodejs version: 6.5.1
  • node version: 12+
@childish-sambino
Copy link
Contributor

Duplicates #841

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate duplicate issue
Projects
None yet
Development

No branches or pull requests

2 participants