The API does not support the click_tracking enable parameter. Or rather, using it (setting it to a boolean value) results in an API error.
https://sendgrid.api-docs.io/v3.0/mail-send/v3-mail-send
{\"errors\":[{\"message\":\"The click_tracking enable parameter is required.\",\"field\":\"tracking_settings.click_tracking.enable\",\"help\":\"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.tracking_settings.click_tracking.enable\"}]}
Make an HTTP request to the /v3/mail/send endpoint with the following payload.
const params = {
content: [
{
type: 'text/html',
value: '<p>Test Email</p>',
},
],
from: {
email: '[email protected]',
name: 'Example Site',
},
subject: 'EMAIL SUBJECT HERE',
tracking_settings: {
// For some reason you can't actually use this:
// Results in error: "The click_tracking enable parameter is required."
// click_tracking: {
// enabled: true, // or false,
// },
},
}
Hi @Xeoncross,
Thanks for bringing this to our attention. I've added this to our backlog for further investigation.
Do you mind sharing the request body?
With Best Regards,
Elmer
I didn't use the sgMail.send(msg) or @sendgrid/helpers. I used the HTTP JSON web v3.0 api (/v3/mail/send).
const Sendgrid = require('sendgrid');
const client = Sendgrid(apiKey);
const request = client.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: params
});
client.API(request, (e, response) => { ...});
Hi @Xeoncross,
What is the value of params?
Also, I recommend using this package as it should make things much easier for you.
With Best Regards,
Elmer
The value of params is shown in the ticket issue (the API params). I need to use the full API so there is currently no reason for me to switch to @sendgrid/mail. The V3 Rest API is working fine for my sends apart from this one param.
Got it, I'll take a deeper look.
I think the issue may be related to how you are formatting the body. Please take a look at this example.
Yes, it was due to using the wrong word form. Thanks for your help.
tracking_settings.click_tracking.enabled
vs
tracking_settings.click_tracking.enable
Most helpful comment
Yes, it was due to using the wrong word form. Thanks for your help.