0
votes

I need to fetch information related to eventId from office 365 for multiple events.

Is there a way I can get that info in a single REST call? I want specific events only (based on eventId's only)

1

1 Answers

1
votes

A batch request may be what you are looking for.

See json Batching Documentation for more information

Keep in mind that batching is currently limited to 20 requests per message (known issues)

Example:

You will need to send a POST Message to the batch endpoint

https://graph.microsoft.com/v1.0/$batch

inside the body you will need to include your requests: Note: do not include the server url (https://graph.microsoft.com/v1.0/) in the url property or the request will fail with "BadRequest - Invalid request Uri".

Request-Body:

  {
      "requests": [
        {
          "id": "1",
          "method": "GET",
          "url": "/me/calendarview?startdatetime=2018-03-01T18:31:34.206Z&enddatetime=2018-03-12T18:31:34.206Z"
        },
                {
          "id": "2",
          "method": "GET",
          "url": "/me/events/{someEventId}"
        },
      ]
}

When the server has processed all requests an response array containing the results will be sent back:

Server-Response:

  {
    "responses": [
            {
        "id": "2",
        "status": 200,
        "headers": {
            "OData-Version": "4.0",
            "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8",
            "ETag": "W/\"Z+ICSvkiAfZX7XWQAZ6IH==\""
        },
        "body": {
           // the event object
        }
    },
        {
            "id": "1",
            "status": 200,
            "headers": {
                "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('aUserID')/calendarView",
                "value": [
                  // list of  found event-objects
                ]
            }
        }
    ]
}