square connect api webhook 更新错误
square connect api webhook update error
我得到
{"type":"bad_request","message":"Unexpected token }"}
来自更新 Webhooks
端点。我正在尝试在 asp.net 中实现它。我的代码块如下:
var httpCLient = new HttpClient();
httpCLient.BaseAddress = new Uri("https://connect.squareup.com");
AuthenticationHeaderValue auth = new AuthenticationHeaderValue("Bearer", "access_token");
httpCLient.DefaultRequestHeaders.Authorization = auth;
httpCLient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpContent content = new StringContent("{\"PAYMENT_UPDATED\"}", System.Text.Encoding.UTF8, "application/json");
Task<HttpResponseMessage> httpResponse = httpCLient.PutAsync("/v1/me/webhooks", content);
if (httpResponse.Result.StatusCode == HttpStatusCode.OK)
{
}
谁能帮我解决这个问题?我已经在 Google 上搜索了任何连接 API 实现 guide/example,但没有成功。
发生此错误是因为请求的事件类型列表必须是 JSON 数组,而不是 JSON 对象。
如果将上例中的 {\"PAYMENT_UPDATED\"}
更改为 [\"PAYMENT_UPDATED\"]
,请求应该会成功。
我得到
{"type":"bad_request","message":"Unexpected token }"}
来自更新 Webhooks
端点。我正在尝试在 asp.net 中实现它。我的代码块如下:
var httpCLient = new HttpClient();
httpCLient.BaseAddress = new Uri("https://connect.squareup.com");
AuthenticationHeaderValue auth = new AuthenticationHeaderValue("Bearer", "access_token");
httpCLient.DefaultRequestHeaders.Authorization = auth;
httpCLient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpContent content = new StringContent("{\"PAYMENT_UPDATED\"}", System.Text.Encoding.UTF8, "application/json");
Task<HttpResponseMessage> httpResponse = httpCLient.PutAsync("/v1/me/webhooks", content);
if (httpResponse.Result.StatusCode == HttpStatusCode.OK)
{
}
谁能帮我解决这个问题?我已经在 Google 上搜索了任何连接 API 实现 guide/example,但没有成功。
发生此错误是因为请求的事件类型列表必须是 JSON 数组,而不是 JSON 对象。
如果将上例中的 {\"PAYMENT_UPDATED\"}
更改为 [\"PAYMENT_UPDATED\"]
,请求应该会成功。