Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/Tests/FlowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/WhatsApp/WhatsAppClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading