1

我可以通过调用获取用户列表,通过调用获取/education/users类列表/education/classes;但是有没有办法让包含外键的类?

到目前为止,我发现这样做的唯一方法是使用/education/users/{id}/classes,但我不想为每个用户都调用它。

上述端点返回的示例:

/education/users

{
    "surname"=>"Wyatt", 
    "usageLocation"=>"CA", 
    "userPrincipalName"=>"DWyatt@fairviewss.onmicrosoft.com", 
    "userType"=>"Member", 
    "middleName"=>"Robert", 
    "externalSource"=>"sis", 
    "primaryRole"=>"teacher", 
    "teacher"=>{
        "teacherNumber"=>"105", 
        "externalId"=>"14005"
    }
}

education/classes

{
    "id"=>"6981f588-c561-4156-8eb9-d733360e3d76", 
    "description"=>"Super science", 
    "displayName"=>"Science", 
    "mailNickname"=>"Science"
}, 
{
    "id"=>"788ee4cd-82a4-4c39-a9e5-0ce6c1877a09", 
    "description"=>"Math", 
    "displayName"=>"Math", 
    "mailNickname"=>"Math"
}, 
{
    "id"=>"9c4af1e4-98eb-4cb0-9288-95b5defe4579", 
    "description"=>nil, 
    "displayName"=>"Science - Biology 1", 
    "mailNickname"=>"Section_11018", 
    "classCode"=>"11018", 
    "externalName"=>"Science - Biology 1", 
    "externalId"=>"11018", 
    "externalSource"=>"sis", 
    "term"=>{
        "externalId"=>"12000", 
        "startDate"=>"2017-07-01", 
        "endDate"=>"2018-06-30", 
        "displayName"=>"SY1516"
    }
}

我确定我做错了什么,我只是不确定是什么。

4

1 回答 1

0

您可以使用以下方法将教师包括在课程列表中$expand=teachers

/v1.0/education/classes?$expand=teachers 

如果您在 Graph Explorer 中执行此操作,您将获得一个class对象集合,其中包括与每个班级关联的教师:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#education/classes",
    "value": [{
            "id": "ef18b112-d6dc-4b56-8cee-85f82dbe8a7d",
            "description": "Presentation Skills 101 training",
            "displayName": "Presentation Skills 101",
            "mailNickname": "PresentationSkills101",
            "teachers@odata.context": "https://graph.microsoft.com/v1.0/$metadata#education/classes('ef18b112-d6dc-4b56-8cee-85f82dbe8a7d')/users",
            "teachers": [{
                "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
                "accountEnabled": true,
                "displayName": "Megan Bowen",
                "givenName": "Megan",
                "surname": "Bowen",
                "userPrincipalName": "MeganB@M365x214355.onmicrosoft.com",
                "userType": "Member",
                "primaryRole": "teacher"
            }]
        }
    }
    ...
于 2018-06-22T17:27:59.033 回答