ED2 KC- 413 Payload is Too Large
March 2021 Update: The easiest thing to do is try importing the files as a Zip and the server should accept
When the Import App just goes blank and doesn’t leave an error in the app’s “console”, check the JS console in your browser’s Dev Tools. You’ll like get have an error like this:
helper.js:110 POST SERVER/api/dataValueSets.json?
dataElementIdScheme=UID&dryRun=false&idScheme=UID&orgUnitIdScheme=UID
&preheatCache=false&skipExistingCheck=false&strategy=UPDATES&skipAudit=false
&format=csv&async=true&firstRowIsHeader=true 413
This is the import app failing to POST a dataset to the dataValueSets endpoint. See the 413 at the end? That is the HTTP Response Code.
The 413 response code happens to be mean the Payload is Too Large. In layman’s terms, the file is too big for the specification on the server.
The HTTP 413 Payload Too Large
response status code indicates that the request entity is larger than limits defined by server; the server might close the connection or return a Retry-After
header field.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413
How to fix it:
You’re going to need to submit a ticket to the system’s team to change this setting, but here is how you fix this issue.
- Reduce the number of records in your file
- Easier said than done when you have a ton of data to import.
- Chunk the file and import them programmatically
- Eh, yea but may not be best for the situation. I.e. The client is routinely importing these files.
- Change the
client_max_body_size
parameter in the NGINXperformance.conf
file.java /etc/nginx/conf.d/performance.conf
By default, NGINX blocks all files on our servers that are larger than 16 Megabytes (16M). This can be changed in the config file. Then restart NGINX and voila.
Don’t forget: hot tip: we tend to use this when restarting tomcat because it tests the config to make sure it is valid before restarting:
3:41
nginx -t && nginx -s reload
Side Note on NGINX Reload vs Restart: When adding or editing server blocks default to reload
over restart
. On reload, Nginx loads the new configuration, starts new worker processes with the new configuration, and gracefully shuts down old worker processes. Restart the service only when making significant modifications like changing ports or interfaces.
Hot Tip (courtesy of Matt Helbing): we tend to use this when restarting tomcat because it tests the config to make sure it is valid before restarting: nginx -t && nginx -s reload
the &&
means do the second command only if first succeeds_._
/