call_batch_endpoint: Call the Graph API batch endpoint

View source: R/batch.R

call_batch_endpointR Documentation

Call the Graph API batch endpoint

Description

Call the Graph API batch endpoint

Usage

call_batch_endpoint(token, requests = list(), depends_on = NULL,
  api_version = getOption("azure_graph_api_version"))

Arguments

token

An Azure OAuth token, of class AzureToken.

requests

A list of graph_request objects, representing individual requests to the Graph API.

depends_on

An optional named vector, or TRUE. See below.

api_version

The API version to use, which will form part of the URL sent to the host.

Details

Use this function to combine multiple requests into a single HTTPS call. This can save significant network latency.

The depends_on argument specifies the dependencies that may exist between requests. The default is to treat the requests as independent, which allows them to be executed in parallel. If depends_on is TRUE, each request is specified as depending on the immediately preceding request. Otherwise, this should be a named vector or list that gives the dependency or dependencies for each request.

There are 2 restrictions on depends_on:

  • If one request has a dependency, then all requests must have dependencies specified

  • A request can only depend on previous requests in the list, not on later ones.

A request list that has dependencies will be executed serially.

Value

A list containing the responses to each request. Each item has components id and status at a minimum. It may also contain headers and body, depending on the specifics of the request.

See Also

graph_request, call_graph_endpoint

Microsoft Graph overview, Batch endpoint documentation

OData documentation on batch requests

Examples

## Not run: 

req1 <- graph_request$new("me")

# a new email message in Outlook
req_create <- graph_request$new("me/messages",
    body=list(
        body=list(
            content="Hello from R",
            content_type="text"
        ),
        subject="Hello",
        toRecipients="bob@example.com"
    ),
    http_verb="POST"
)

# messages in drafts
req_get <- graph_request$new("me/mailFolders/drafts/messages")

# requests are dependent: 2nd list of drafts will include just-created message
call_batch_endpoint(token, list(req_get, req_create, req_get), depends_on=TRUE)

# alternate way: enumerate all requests
call_batch_endpoint(token, list(req_get, req_create, req_get), depends_on=c("2"=1, "3"=2))


## End(Not run)

AzureGraph documentation built on Sept. 8, 2023, 5:53 p.m.