call_batch_endpoint | R Documentation |
Call the Graph API batch endpoint
call_batch_endpoint(token, requests = list(), depends_on = NULL,
api_version = getOption("azure_graph_api_version"))
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. |
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.
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.
graph_request, call_graph_endpoint
Microsoft Graph overview, Batch endpoint documentation
OData documentation on batch requests
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.