0

我越来越

{"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 实施指南/示例,但没有运气。

4

1 回答 1

0

发生此错误是因为请求的事件类型列表必须是 JSON 数组,而不是 JSON 对象。

如果您在上面的示例中更改{\"PAYMENT_UPDATED\"}为,请求应该会成功。[\"PAYMENT_UPDATED\"]

于 2015-01-20T20:38:38.430 回答