Batch API on /v1.0/$batch returns invalid JSON when one element receives a 503

Joe Jones 0 Reputation points
2025-09-02T14:32:25.16+00:00

When we make a batched request to the /v1.0/$batch endpoint and one of the elements in the batch fails with a 503 we get this response structure.

To be clear the whole request returns a 200 status code and other elements in the response are formatted correctly.

{
    "id": "REDACTED",
    "status":503,
    "headers": {
        "Content-Type": "text/html; charset=us-ascii"
    },
    "body":<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\r\n<HTML><HEAD><TITLE>Service Unavailable</TITLE>\r\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=us-ascii\"></HEAD>\r\n<BODY><h2>Application Request Queue Full</h2>\r\n<hr><p>HTTP Error 503. The application request queue is full.</p>\r\n</BODY></HTML>
}

This is not valid JSON. We are then unable to process the response to determine which elements of the batch errored out.

The endpoint we're trying to use in the batch request is /users/EMAIL/mailFolders/inbox/messageRules obviously replacing EMAIL with a user's email.

This is pretty frustrating from a development point of view. There's nothing we can do with the response other than retry the whole batch. Sometimes we get consecutive retries that fail.

Looks like this is an ongoing issue to with it here on stack overflow - https://stackoverflow.com/questions/67793848/graph-json-response-seldom-contains-raw-html

and here in the MS graph SDK https://github.com/microsoftgraph/msgraph-sdk-serviceissues/issues/93

Microsoft Security | Microsoft Graph

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.