microsoft-graph-apimicrosoft-graph-edu

Retrieving education class data from Microsoft Graph


I'm currently looking at switching from using the Groups API to the Education API.

I'm using the Graph Explorer to test some endpoints and I keep seeing the following in some of the responses (I've changed sensitive values):


{
  "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.educationClass)",
  "value":[{
    "id":"ID",
    "description":null,
    "displayName":"NAME",
    "mailNickname":"Section_BLAH_BLAH",
    "externalName":"NAME",
    "externalId":"BLAH_BLAH",
    "externalSource":"sis"
    {
      "error": {
        "code": "InternalServerError",
        "message": "String was not recognized as a valid DateTime.",
        "innerError": {
          "request-id": "XXXXX-b7c9-4c83-94ed-XXXXX",
          "date": "2019-12-04T12:36:57"
        }

The requested endpoint was https://graph.microsoft.com/v1.0/education/schools/SCHOOL_ID/classes, which I would expect to return a list of Classes for the School.

The data was added via SDS, so I'm not sure if that could be the problem, or there was a problem when adding the class data


Solution

  • From the error, it seems like a datetime property is not properly formed. JSON serializers like Newtonsoft and Json.net handles this out of the box. But if you form your own JSON, you must ensure that the date is on ISO 8601 format, meaning yyyy-MM-ddTHH:mm:ssZ.

    In C#, this is done with myDate.ToString("o");