Sendgrid-csharp: Transactional Templates not found by SendGridClient Only Legacy Templates are returned...

Created on 15 Aug 2018  路  8Comments  路  Source: sendgrid/sendgrid-csharp

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...

Steps to Reproduce

  //THIS METHOD SHOULD RETURN ALL TEMPLATES IN THE SENDGRID ACCOUNT BUT ONLY RETURNS LEGACY TEMPLATES--

public async Task> GetTemplateIdsByNameAsync()
{

        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?

Technical details:

Asp.Net Core
Latest SendGrid Version

docs update

Most helpful comment

For those who do not use legacy transactional templates, it suffices to use https://api.sendgrid.com/v3/templates?generations=dynamic

All 8 comments

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!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jewpaltz picture jewpaltz  路  3Comments

mawiseman picture mawiseman  路  4Comments

CalvinFengDatacom picture CalvinFengDatacom  路  4Comments

lijaso picture lijaso  路  3Comments

clairernovotny picture clairernovotny  路  4Comments