首页 > 解决方案 > SendGrid Put 请求在应用程序代码中返回 400 响应

问题描述

我正在使用https://sendgrid.com/docs/api-reference/=> 生成的代码PUT /marketing/contacts来添加营销联系人。生成的.net 代码如下。我Response status code does not indicate success: 400 (Bad Request).在我的应用程序中得到了一个,但在 SendGrid 网站上也是如此。

我会错过什么?

var client = new RestClient("https://api.sendgrid.com/v3/marketing/contacts");
var request = new RestRequest(Method.PUT);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer <ClientId>");
request.AddParameter("application/json", "{\"list_ids\":[\"bbb6445d-0d52-488e-ac38-55176369b9f4\"],\"contacts\":[{\"alternate_emails\":[\"ajitgoel@gmail.com\"],\"email\":\"ajitgoel@gmail.com\"}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

标签: c#.netsendgridhttp-status-code-400sendgrid-api-v3

解决方案


推荐阅读