by Anonymous » 27 Dec 2024, 14:06
Mein Problem ist, dass ich ein von einer API gesendetes Objekt nicht extrahieren kann, obwohl ich das Schema des Objekts entweder in der API oder im Client habe. Mein Code:
Code: Select all
public async Task Index()
{
HttpClient client = new HttpClient();
Uri baseAddress = new Uri("http://localhost:44237/");
client.BaseAddress = baseAddress;
HttpResponseMessage response = client.GetAsync("api/Front/Subm?IdSubmission=1xxx").Result;
try
{
if (response.IsSuccessStatusCode)
{
string Result = await response.Content.ReadAsStringAsync();
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
Submission sub = JsonConvert.DeserializeObject(Result);
return View(sub);
}
else
{
}
}
catch (Exception e)
{
}
}
Die im Ergebnis erhaltene Struktur ist

Mein Problem ist, dass ich ein von einer API gesendetes Objekt nicht extrahieren kann, obwohl ich das Schema des Objekts entweder in der API oder im Client habe. Mein Code:
[code] public async Task Index()
{
HttpClient client = new HttpClient();
Uri baseAddress = new Uri("http://localhost:44237/");
client.BaseAddress = baseAddress;
HttpResponseMessage response = client.GetAsync("api/Front/Subm?IdSubmission=1xxx").Result;
try
{
if (response.IsSuccessStatusCode)
{
string Result = await response.Content.ReadAsStringAsync();
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
Submission sub = JsonConvert.DeserializeObject(Result);
return View(sub);
}
else
{
}
}
catch (Exception e)
{
}
}
[/code]
Die im Ergebnis erhaltene Struktur ist
[img]https://i.sstatic.net/ udJoS.png[/img]