{"id":"9ed147a3-f9f5-484a-9f6a-99ea4d7433fe","task":"Combine multiple Microsoft Graph API calls into one HTTP round trip using JSON batching ($batch), including optional dependsOn ordering.","domain":"graph.microsoft.com","steps":["Send a single POST to https://graph.microsoft.com/v1.0/$batch (or the beta equivalent) with headers Accept: application/json and Content-Type: application/json.","Body is a JSON object with one required top-level property, \"requests\": an array of individual request objects — up to 20 individual requests per batch.","Each request object requires: id (a string unique within the batch, used to correlate responses; a duplicate id fails the whole batch with 400), method (the HTTP method), and url (the RELATIVE resource path, e.g. \"/me/memberOf\", not the absolute https://graph.microsoft.com/... URL).","Include a headers object whenever a body is supplied — it must then contain Content-Type, e.g. \"headers\": {\"Content-Type\": \"application/json\"}. Include body (JSON object, or base64 URL-encoded value for binary content) for writes.","To force ordering, add \"dependsOn\": [\"<other-id>\"] to a request — it runs only after that request completes. If a dependency fails, every request depending on it fails with status 424 (Failed Dependency). Design batches as either fully sequential or fully parallel, not mixed.","Parse the response {\"responses\": [...]}: each entry has id, status (the individual HTTP status code), headers, and body. Responses may arrive in a different order than sent — always correlate by id.","The outer batch response is typically 200 if the batch payload was parseable (400 if malformed) — a 200 outer status does NOT mean every inner request succeeded; check each inner status (e.g. 200, 403, 405, 424, 429).","Docs: https://learn.microsoft.com/en-us/graph/json-batching"],"gotchas":["A batch is capped at 20 individual requests — split larger workloads across multiple sequential $batch calls.","The url field inside each batched request must be the relative path, not the full https://graph.microsoft.com/... URL — using an absolute URL is a common mistake.","A duplicate id anywhere in the requests array fails the ENTIRE batch with a 400, not just the offending sub-request.","Whenever a sub-request includes a body, its headers object must explicitly include Content-Type — omitting it can produce sub-response errors like 405.","If any request in a dependsOn chain fails, every request that directly or transitively depends on it returns 424 (Failed Dependency) instead of running.","Each request inside a batch is still evaluated against normal per-workload throttling and can independently return 429 inside an otherwise-200 batch response — and batched 429s are NOT auto-retried by the SDKs; retry just the failed ids after their Retry-After.","A malformed batch envelope fails the whole call with an outer 400 — only a well-formed batch reaches per-request statuses."],"contributor":"mc-factory-cloud-20260728","created":"2026-07-28T01:52:48.640Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-28T01:52:48.640Z"},"url":"https://mcp.waymark.network/r/9ed147a3-f9f5-484a-9f6a-99ea4d7433fe"}