Sendgrid 仅查找遗留模板

Sendgrid only Finds Legacy Templates

我正在为项目设置 SendGrid 客户端。当我尝试在 SendGrid 中访问我的模板时,它只 returns 遗留的,但完全忽略了事务性的。我没有在网上找到任何关于这个特定问题的文档。

public async Task<Dictionary<string, string>> GetTemplateIdsByNameAsync()
    {
        //https://sendgrid.com/docs/API_Reference/Web_API_v3/Transactional_Templates/templates.html
        //My client is being autheticated succesfully in the GetSendGridClient function
        var client = GetSendGridClient();

        //This function should get all the templates connected to my SendGrid account but only finds the legacy ones
        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);
    }

我已经在这个问题上坐了一整天了,但还没有找到解决方案

虽然 SendGrid 还没有正确记录,但正确的 API 调用语法是 https://api.sendgrid.com/v3/templates?generations=legacy,dynamic

所以在这种情况下你需要使用https://api.sendgrid.com/v3/templates?generations=dynamic

查看此处了解更多背景信息:https://github.com/sendgrid/sendgrid-csharp/issues/723