我可以通过调用/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"
}
}
我确定我弄错了,我只是不确定是什么。
答案 0 :(得分:0)
您可以使用$expand=teachers
将教师包括在班级列表中:
/v1.0/education/classes?$expand=teachers
如果您execute this in 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"
}]
}
}
...