diff --git a/src/Tests/FlowTests.cs b/src/Tests/FlowTests.cs index 22a6887..c2f8c14 100644 --- a/src/Tests/FlowTests.cs +++ b/src/Tests/FlowTests.cs @@ -21,6 +21,15 @@ namespace Devlooped.WhatsApp; public class FlowTests(ITestOutputHelper output) { + static readonly JsonSerializerOptions jsonOptions = new(JsonSerializerDefaults.Web) + { + DefaultIgnoreCondition = + System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault | + System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + WriteIndented = true, + }; + [Fact] public void VerifyFlowRequest() { @@ -108,11 +117,11 @@ public async Task SendFlowNavigateData() data = new { agent = "list", - service = "5678", - user = "pga", + service = "5678📝🧮", + user = "pgaña", flow = "data", }, - }) + }, jsonOptions) }); var sent = await response.SendAsync(client); diff --git a/src/WhatsApp/WhatsAppClient.cs b/src/WhatsApp/WhatsAppClient.cs index ece1a64..5eb9be4 100644 --- a/src/WhatsApp/WhatsAppClient.cs +++ b/src/WhatsApp/WhatsAppClient.cs @@ -73,7 +73,7 @@ public HttpClient CreateHttp(string numberId) http.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", $"Bearer {token}"); http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - var result = await http.PostAsJsonAsync($"https://graph.facebook.com/{options.ApiVersion}/{numberId}/messages", payload, cancellationToken); + var result = await http.PostAsJsonAsync($"https://graph.facebook.com/{options.ApiVersion}/{numberId}/messages", payload, jsonOptions, cancellationToken); if (!result.IsSuccessStatusCode) {