# maxBodyLength limit

**URL:** <https://discuss.elastic.co/t/maxbodylength-limit/351162>\
**Category:** Kibana\
**Created:** [January 16, 2024, 12:17pm UTC](https://discuss.elastic.co/t/maxbodylength-limit/351162 "2024-01-16T12:17:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdranger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fdranger/32/127656_2.png) [@fdranger](https://discuss.elastic.co/u/fdranger)\
**Post date:** [January 16, 2024, 12:17pm UTC](https://discuss.elastic.co/t/maxbodylength-limit/351162/1 "2024-01-16T12:17:37Z")

</div>

log:

```auto
callAsCurrentUser:scroll|{"scrollId":"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA_Q-QWOHdpMWswdlRUamlNX0hoVDBWUFowZw==","scroll":"1m","headers":{"x-kbn-domain":" ******","x-kbn-user":"******"}};;undefined
{"type":"log","@timestamp":"2024-01-16T08:06:12Z","tags":["license","debug","xpack"],"pid":13,"message":"Calling [data] Elasticsearch _xpack API. Polling frequency: 30001"}
{"type":"error","@timestamp":"2024-01-16T08:06:08Z","tags":[],"pid":13,"level":"error","error":{"message":"Request body larger than maxBodyLength limit","name":"Error","stack":"Error: Request body larger than maxBodyLength limit\n at RedirectableRequest.write (/root/kibana-7.4.2-SNAPSHOT-linux-x86_64/node_modules/follow-redirects/index.js:97:24)\n at RedirectableRequest.end (/root/kibana-7.4.2-SNAPSHOT-linux-x86_64/node_modules/follow-redirects/index.js:116:8)\n at dispatchHttpRequest (/root/kibana-7.4.2-SNAPSHOT-linux-x86_64/node_modules/axios/lib/adapters/http.js:235:11)\n at new Promise (<anonymous>)\n at httpAdapter (/root/kibana-7.4.2-SNAPSHOT-linux-x86_64/node_modules/axios/lib/adapters/http.js:18:10)\n at dispatchRequest (/root/kibana-7.4.2-SNAPSHOT-linux-x86_64/node_modules/axios/lib/core/dispatchRequest.js:59:10)\n at process._tickCallback (internal/process/next_tick.js:68:7)"},"url":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":"?fields=title&per_page=10000&type=index-pattern","query":{"fields":"title","per_page":"10000","type":"index-pattern"},"pathname":"/api/saved_objects/_find","path":"/api/saved_objects/_find?fields=title&per_page=10000&type=index-pattern","href":"/api/saved_objects/_find?fields=title&per_page=10000&type=index-pattern"},"message":"Request body larger than maxBodyLength limit"}

```

version: 7.4.2

desc: I modified the SavedObjectsRepository.find() method to obtain a large amount of index-patterns(more than 20K pieces) through scrolling query, but i got the error above. I'm curious how to increase `maxBodyLength` in Kibana.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [January 17, 2024, 10:42am UTC](https://discuss.elastic.co/t/maxbodylength-limit/351162/2 "2024-01-17T10:42:22Z")

</div>

Hi @fdranger,

Welcome to the community! Can you share the query, code snippet or action that is triggering this error?

Just a heads up that version 7.4.2 is past EOL so we would recommend upgrading if you can.

Let us know!

---

<div class="post-metadata">

**Author:** ![fdranger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fdranger/32/127656_2.png) [@fdranger](https://discuss.elastic.co/u/fdranger)\
**Post date:** [January 17, 2024, 5:03pm UTC](https://discuss.elastic.co/t/maxbodylength-limit/351162/3 "2024-01-17T17:03:11Z")

</div>

Thank you!  
This is the code snippet

repository.ts:

```auto
async find<T extends SavedObjectAttributes = any>({
  search,
  defaultSearchOperator = "OR",
  searchFields,
  hasReference,
  page = 1,
  perPage = 20,
  sortField,
  sortOrder,
  fields,
  namespace,
  type
}: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>> {
  
  ······
  ······

  let response = await this._callCluster("search", esOptions);

  if (response.status === 404) {
    // 404 is only possible here if the index is missing, which
    // we don't want to leak, see "404s from missing index" above
    console.log("warn", `Index not found: ${esOptions.index}`);
    return {
      page,
      per_page: perPage,
      total: 0,
      saved_objects: []
    };
  }
  const hitsTotal = response.hits.total;
  let hitsLength = response.hits.hits.length;

  let hits = response.hits.hits;

  if (hitsTotal > hitsLength) {
    while (hitsLength > 0) {
      const scrollId = response._scroll_id;
      response = await this._callCluster("scroll", {
        scrollId,
        scroll: "1m"
      });
      hitsLength = response.hits.hits.length;
      hits = hits.concat(response.hits.hits);
    }
  }
  console.log(`hits total: ${hits.length}`);

  return {
    page,
    per_page: perPage,
    total: response.hits.total,
    saved_objects: hits.map((hit: RawDoc) => this._rawToSavedObject(hit))
  };
}

```

BTW there is a proxy between Kibana and ES for filtering and forwarding requests.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 14, 2024, 5:03pm UTC](https://discuss.elastic.co/t/maxbodylength-limit/351162/4 "2024-02-14T17:03:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
