public void SerializePayload_ShouldWork() { Product product = _products[0]; WebhookPayload payload = new WebhookPayload(product); string json = payload.SerializePayload(); Assert.True(json.Length > 0); }
private async Task SendWebhook(string url, WebhookPayload payload) { var httpContent = new StringContent(payload.SerializePayload(), Encoding.UTF8, "application/json"); var httpResponse = await _webClient.PostAsync(url, httpContent); if (httpResponse.Content != null) { string responseContent = await httpResponse.Content.ReadAsStringAsync(); if (responseContent.Length > 0) { Log.Logger.Warning($"Payload could not be sent"); throw new Exception(responseContent); } } }