1

我正在尝试从班级端点检索学生所属的所有学校:

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"
          }
      }
  }
4

1 回答 1

0

为了同时利用$expandand $select,您需要包含id. 这提供了 Graph 连接两者之间的点所需的键值。

例如,此查询将失败:

/beta/education/users/{id}?$expand=schools&$select=userPrincipalName,student,schools

但是通过添加id到 select 参数,它将返回预期的结果:

/beta/education/users/{id}?$expand=schools&$select=id,userPrincipalName,student,schools
于 2021-03-01T23:13:09.410 回答