I'm getting
{"type":"bad_request","message":"Unexpected token }"}
from Update Webhooks
endpoint. I'm trying to implement this in asp.net. My code block is following:
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)
{
}
Can anyone help me with this? I've already searched for any connect API implementation guide/example on Google, but no luck.
This error is occurring because the list of requested event types must be a JSON array, not a JSON object.
The request should succeed if you change {\"PAYMENT_UPDATED\"}
to [\"PAYMENT_UPDATED\"]
in the above example.