我正试图从班级端点检索学生所属的所有学校:
https://graph.microsoft.com/beta/education/classes/{classId}/members?$expand=schools&$select=userPrincipalName,student,schools
物业学校显示在回复上,但总是空的:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.educationUser)",
"value": [
{
"userPrincipalName": "some@mail",
"student": {
"grade": "XXXXXXX",
"studentNumber": "XXXXXX"
},
"schools": []
},
{
"userPrincipalName": "some@mail",
"student": {
"grade": "XXXXXXX",
"studentNumber": "XXXXXX"
},
"schools": []
}
]
}
编辑:我确认schools
属性对我来说总是空的。甚至教育用户端点也不再工作:https://graph.microsoft.com/beta/education/users/{userId}?$expand=schools&$select=userPrincipalName,student,schools
。
这里的错误我得到:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#education/users(userPrincipalName,student,schools,schools())/$entity",
"userPrincipalName": "some@mail",
"student": {
"externalId": "XXXXXXX",
"grade": "XXXX",
"studentNumber": "XXXXX"
}{
"error": {
"code": "InternalServerError",
"message": "The entity instance value of type 'microsoft.graph.educationUser' doesn't have a value for property 'id'. To compute an entity's metadata, its key and concurrency-token property values must be provided.",
"innerError": {
"date": "2020-09-17T07:54:02",
"request-id": "d60fc284-e410-4e39-a2db-52cb1da5f0bf",
"client-request-id": "d60fc284-e410-4e39-a2db-52cb1da5f0bf"
}
}
}
为了同时利用$expand
和$select
,您需要包含id
。这提供了Graph连接两者之间的点所需的关键值。
例如,此查询将失败:
/beta/education/users/{id}?$expand=schools&$select=userPrincipalName,student,schools
但通过在选择参数中添加id
,它将返回预期结果:
/beta/education/users/{id}?$expand=schools&$select=id,userPrincipalName,student,schools