You get a "too large body" error

Many Identity Cloud endpoints use body parameters as a way to specify properties and property values for Identity Cloud objects. For example, when creating a login policy, you might use a JSON-formatted body parameter similar to this:

{
     "identityStoreDetails": {
        "type": "janrainCapture",
        "connectionDetails": {
            "domain": "us-dev.janraincapture.com",
            "applicationId": "ces7u7uwwudrxtz933jvbehzne",
            "entityType": "user",
            "clientId": "6s7q89env535ek49hkz6hjsh3jgs93ud",
            "clientSecret": "8c8frzvtxuoqbb7ayewvbgvn67s5dctx"
        }
    },
    "loginURL": "https://v1.api.us.janrain.com/e0a70b4f-1eef-4856-bcdb-f050fee66aae/auth-ui/login",
    "title": "Training Login Policy"
}

Other API endpoints might use a different type of body parameter (e.g., x-www-form-urlencoded), but these endpoints still rely on the body parameter.

Typically body parameters are quite small; the login policy example shown a moment ago contains just 507 characters. At times, however, body parameters can be considerably larger; for example, the entity.bulkCreate endpoint might be used to create several thousand user accounts in a single operation. In turn, that's going to result in a much larger body parameter, and could even result in a body parameter too large to be used.

And what does "too large to be used" even mean? Well, by default Identity Cloud body parameters can be no larger than 5 MB; if you try to make an API call with, say, a 6 MB body parameter, that's going to fail with an error similar to this:

client intended to send too large  body: 6291456 bytes

Your body parameter's can't exceed 5 MB. That's all there is to it.

📘

There are two exceptions to this 5 MB rule: the Published Settings endpoints and the OAuth User Profile endpoints. These endpoints are limited to a maximum body parameter size of 1 MB. Which, needless to say, is even smaller than 5 MB.

So what can you do if you run into these size limitations? Well, to begin, there's a good chance you won't run into these size limitations: 5 MB (or even 1 MB) is a very large body parameter. But suppose you do encounter this error when trying to add several thousand new user accounts by using the entity.bulkCreate endpoint. In that case, you can simply split your user list in half (say, last names A-M and last names N-Z) and then make two calls to the entity.bulkCreate endpoint: the first time using users A-M and the second time using users N-Z.


Did this page help you?