Merge pull request #4296 from hhunter-ms/issue_4283

[Service invocation] Update .NET example for invoking HTTP
This commit is contained in:
Hannah Hunter 2024-08-07 10:48:54 -04:00 committed by GitHub
commit b59a1b02f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 4 deletions

View File

@ -242,12 +242,10 @@ namespace EventService
var orderId = random.Next(1,1000);
//Using Dapr SDK to invoke a method
var order = new Order("1");
var orderJson = JsonSerializer.Serialize<Order>(order);
var content = new StringContent(orderJson, Encoding.UTF8, "application/json");
var order = new Order(orderId.ToString());
var httpClient = DaprClient.CreateInvokeHttpClient();
var response = await httpClient.PostAsJsonAsync("http://order-processor/orders", content);
var response = await httpClient.PostAsJsonAsync("http://order-processor/orders", order);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Order requested: " + orderId);