Instantly share code, notes, and snippets.

Embed
What would you like to do?
Microsoft Graph API JSON Batching Request Example
$myBatchRequests = @()
[int]$requestID = 0
$requestID ++
$myRequest = [pscustomobject][ordered]@{
id = $requestID
method = "GET"
url = "/users?`$filter=(startswith(displayName,`'$($userSearchNameEncoded)`'))&`$top=10"
}
$myBatchRequests += $myRequest
$requestID ++
$myRequest = [pscustomobject][ordered]@{
id = $requestID
method = "GET"
url = "/security/alerts?`$top=20"
}
$myBatchRequests += $myRequest
$allBatchRequests = [pscustomobject][ordered]@{
requests = $myBatchRequests
}
$batchBody = $allBatchRequests | ConvertTo-Json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment