【问题标题】:square connect api webhook update errorsquare connect api webhook 更新错误
【发布时间】:2015-01-21 04:38:38
【问题描述】:

我来了

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

【问题讨论】:

    标签: webhooks square-connect


    【解决方案1】:

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

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

    【讨论】:

    • 非常感谢,这解决了问题,也明白了关于 JSON 数组的观点。
    猜你喜欢
    • 2016-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    相关资源
    最近更新 更多