我试图获取通过.net客户端定义的新动态模板,但是我只能设法检索它们现在称为“旧版”模板的列表。这就是我所拥有的(只是添加了queryParams,但似乎被忽略了):
var test1 = @"{
'generation': 'dynamic'
}";
var test2 = "{\"generation\": \"dynamic\"}";
var response = await _client
.RequestAsync(method: SendGridClient.Method.GET,
urlPath: "templates", queryParams: test2);
var responseBody = await response.Body
.ReadAsStringAsync();
var templateList = JsonConvert
.DeserializeObject<SendGridTemplateList>(responseBody);
return templateList?
.Templates.FirstOrDefault(x => x.Name.Contains(templateName))?
.Versions.FirstOrDefault(x => x.Active == 1);
答案 0 :(得分:0)
似乎我在某个地方感到困惑,正确的方法是只编辑urlPath:
var response = await _client
.RequestAsync(method: SendGridClient.Method.GET,
urlPath: $"templates?generations=dynamic");