skip to Main Content

Json – What's the best way to get result from ReadAsStringAsync response?

What I have This code calling my API: HttpResponseMessage response = await Http.GetAsync("https://localhost:7094/api/MyResource/94d0e5ca-2be7-42f7-94dc-13955c11595c"); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine($"RESPONSE: {responseBody}"); var payload = JsonSerializer.Deserialize<MyClass>(responseBody); var json = JsonSerializer.Serialize(payload); Console.WriteLine($"PAYLOAD: {json}"); This code is called from OnInitializedAsync in a NET8…

VIEW QUESTION
Back To Top
Search