我正在
{"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实施指南/示例,但没有运气。
答案 0 :(得分:0)
发生此错误是因为请求的事件类型列表必须是JSON数组,而不是JSON对象。
如果您在上面的示例中将{\"PAYMENT_UPDATED\"}
更改为[\"PAYMENT_UPDATED\"]
,请求应该会成功。