microsoft-graph-apimicrosoft-teamsmicrosoft-graph-edu

Microsoft Graph - Education user batch request not returning a value property


Running batch requests against most Microsoft Graph API endpoints returns a object with a value property like this:

{
        "id": "2",
        "status": 200,
        "headers": {
            "Cache-Control": "no-cache",
            "x-ms-resource-unit": "1",
            "OData-Version": "4.0",
            "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
        },
        "body": {
            "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,student,teacher)",
            "value": [
                {
                    "id": "ebe6297c-1f76-484e-9616-5e8e6be6098e",
                    "displayName": "Adele Vance"
                }
            ]
        }
    },

However running a batch request against /education/user/{userId} gives me:

 {
        "id": "1",
        "status": 200,
        "headers": {
            "Cache-Control": "no-cache",
            "OData-Version": "4.0",
            "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
        },
        "body": {
            "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#education/users(id,displayName,student,teacher)/$entity",
            "id": "ebe6297c-1f76-484e-9616-5e8e6be6098e",
            "displayName": "Adele Vance"
        }
    }

Without any value property. This looks like a bug. Not sure how to proceed.

Best regards, Oskar


Solution

  • It depends on the endpoint you are calling in batch request.

    For endpoints returning a collection, the batch response contains "value": [{..},..] in body...collection of objects.

    For endpoints (like your endpoint GET /education/users/{id} that return single object, the batch response contains the object.