FirelyTeam/firely-docs-firely-server

Request body too large. The max request body size is 1048576 bytes.

Closed this issue · 1 comments

Hi,

I'm trying to set the MaxRequestBodySize and I've tried to change the value in app.appsettings.default.json and/or appsettings.instance.json by adding the fragment:

  "Hosting": {
     "Limits": {
           "MaxRequestBufferSize": 2097152,
           "MaxRequestBodySize": 2147483647
        }
  }

I check the logs and it seems the value is being loaded:

image

However whenever I attempt to perform a request with a large body the server returns the following response with (what I presume to be is) a default value that is not the one I set.

StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Date: Mon, 18 Sep 2023 13:43:53 GMT
  Server: Kestrel
  Cache-Control: no-store
  custom-correlation-id: ee8a5bdc-ce97-431c-831f-723915403726
  Content-Length: 942
  Content-Type: application/fhir+xml; fhirVersion=4.0; charset=utf-8
}
<OperationOutcome xmlns="http://hl7.org/fhir">
  <id value="e32ce02d-4526-48a1-a8da-74ee2e0c77f1" />
  <meta>
    <versionId value="945134e0-ef2e-4c04-943e-6e521f2b9240" />
    <lastUpdated value="2023-09-18T13:43:54.3270403+00:00" />
  </meta>
  <issue>
    <severity value="error" />
    <code value="invalid" />
    <details>
      <coding>
        <system value="http://hl7.org/fhir/dotnet-api-operation-outcome" />
        <code value="5002" />
      </coding>
      <text value="Request body too large. The max request body size is 1048576 bytes." />
    </details>
  </issue>
  <issue>
    <severity value="warning" />
    <code value="not-supported" />
    <details>
      <coding>
        <system value="http://hl7.org/fhir/dotnet-api-operation-outcome" />
        <code value="5003" />
      </coding>
      <text value="Argument is not supported" />
    </details>
    <diagnostics value="/Bundle" />
  </issue>
</OperationOutcome>

Any chance anyone knows what I'm missing here? I assume I am either editing the wrong file or am not using the correct setting key. Sadly the FHIR profile I have to follow demands that images must be base64ed into the request which means I cannot avoid triggering the limits.

Sorry if this is the wrong place to ask this but I really don't know who/where to ask.

Ah, I was wrong about the setting. I needed to change:

"SizeLimits": {
    "MaxResourceSize": "1MiB",
    "MaxBatchSize": "5MiB",
    "MaxBatchEntries": 150
},

where MaxResourceSize seemed to be the limiting factor. This config is referenced here but clearly I did not read it thoroughly enough.

Sorry to trouble you.