Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active January 7, 2019 21:48
Show Gist options
  • Save darrenjrobinson/80daf71401644e3ba28e03843defd855 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/80daf71401644e3ba28e03843defd855 to your computer and use it in GitHub Desktop.
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