I Set up a SendGridClient for a project in my company, I have a function which gets all the templates from my SendGridAccount and then picks the right one for a certain mail based on the name of the Template in the SendGridAccount. However SendGridClient only returns Legacy Templates but not the Transactional which I would like to use so I can utilize handlebars, if/else logic etc...
//THIS METHOD SHOULD RETURN ALL TEMPLATES IN THE SENDGRID ACCOUNT BUT ONLY RETURNS LEGACY TEMPLATES--
public async Task
{
var client = GetSendGridClient();
var response = await client.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "templates");
ThrowExceptionIfStatusIsNotOk(response);
var content = await response.Body.ReadAsStringAsync();
var anonymousTemplatesObject = new { Templates = new[] { new { Id = "", Name = "" } } };
var templates = _genericJsonSerializer.DeserializeAnonymous(content, anonymousTemplatesObject);
return templates.Templates.ToDictionary(x => x.Name, x => x.Id);
}
I would expect the client to return all the templates ore is there a setting I have overlooked?
Asp.Net Core
Latest SendGrid Version
Hi @Pieter-1337,
Thanks for bringing this to our attention. The correct API call is https://api.sendgrid.com/v3/templates?generations=legacy,dynamic. I will leave this ticket open so that we can implement this formally.
For now, please try:
var response = await client.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "templates?generations=legacy,dynamic");
With Best Regards,
Emer
For those who do not use legacy transactional templates, it suffices to use https://api.sendgrid.com/v3/templates?generations=dynamic
Thanks for the clarification @kgehmlich!
Perhaps you can add the parameter to the apidoc in the meantime? I had the same problem yesterday (php, js sdks and direct call to the ws) and I couldn't seem to find it documented anywhere here https://sendgrid.com/docs/API_Reference/api_v3.html. Thanks!
Hello @omissis,
I believe this is on the documentation team's backlog currently. (cc @ksigler7 @Whatthefoxsays)
Thanks!
Elmer
@thinkingserious thanks :)
Thank you for pointing out. But 6 month+ for adding a small but essential description to the doc is too LONGGG!!!
Docs have been updated: https://sendgrid.com/docs/API_Reference/api_v3.html
Most helpful comment
For those who do not use legacy transactional templates, it suffices to use
https://api.sendgrid.com/v3/templates?generations=dynamic