C# 将JSON响应转换为Graph.EducationAssignment对象

C# 将JSON响应转换为Graph.EducationAssignment对象,c#,microsoft-graph-api,microsoft-graph-edu,C#,Microsoft Graph Api,Microsoft Graph Edu,当我尝试将JSON响应转换为Graph.EducationAssignment根对象时,没有数据。我没有收到错误消息,只是一个空对象 我打电话给/beta/education/classes/{classId}/assignments httpresponsemessageresponse=wait-HttpClient.GetAsync(webapirl); if(响应。IsSuccessStatusCode) { string json=wait response.Content.ReadA

当我尝试将JSON响应转换为
Graph.EducationAssignment
根对象时,没有数据。我没有收到错误消息,只是一个空对象

我打电话给
/beta/education/classes/{classId}/assignments

httpresponsemessageresponse=wait-HttpClient.GetAsync(webapirl);
if(响应。IsSuccessStatusCode)
{
string json=wait response.Content.ReadAsStringAsync();
Microsoft.Graph.EducationAssignment作业=
反序列化对象(json);
//列表分配1=
//反序列化对象(json);
}
由于响应的大小,这里是第一行,它显示分配保存在一个数组中

{
“@odata.context”:”https://graph.microsoft.com/beta/$metadata#教育/课程('id')/作业“,
“价值”:[
{
“classId”:“诸如此类”,
“displayName”:“无家可归者”,
“closeDateTime”:空
如果有人能帮我,我将不胜感激


您没有描述Microsoft.Graph.EducationAssignment的外观或来源。最可能的问题是,您试图将资源集合(包含在
值中)反序列化为单个对象

除非您熟悉OData和JSON序列化,否则我不会尝试手工制作您自己的图形客户端。您将更轻松地使用。SDK将为您处理所有这些,并且您将得到更干净的代码:

var assignments = await graphClient
    .Education
    .Classes["id"]
    .Assignments
    .Request()
    .GetAsync();

var assignment = await graphClient
    .Education
    .Classes["id"]
    .Assignments["id"]
    .Request()
    .GetAsync();


据我所知,Microsoft.Graph.EducationAssignment是一个内置类。例如,Microsoft.Graph.EducationAssignment Assignments=new Microsoft.Graph.EducationAssignments();如果您使用SDK,为什么不使用它来填充对象?