When issuing a POST
request with a large body to my Play framework action method, I get null
when extracting the data. If the body is fairly small, I can retrieve the data just fine.
Here's a sample short data set:
{
"creator": "zoltan",
"sport": "hike",
"geometry": [
{
"time": "2009-07-10 12:56:10 +0000",
"x": 10.275514,
"y": 47.514749,
"z": 756.587
},
{
"time": "2009-07-10 12:56:19 +0000",
"x": 10.275563,
"y": 47.514797,
"z": 757.417
}
]
}
When I issue a POST
request with this JSON in the body, everything works fine. However, if I add many more (~4000) points in the geometry
array, I get null
in the action.
Here's my action method:
@Transactional
//@BodyParser.Of(Json.class) // tried with this as well
public static Result createTour() {
LOG.debug("Raw request body: " + request().body().asText());
JsonNode node = request().body().asJson();
LOG.debug("JSON request body: " + node);
TourDto tourDto;
try {
tourDto = jsonToTour(node);
int id = TourDataAccessUtils.create(tourDto);
return created(toJson(id));
} catch (JsonProcessingException e) {
LOG.error("While parsing JSON request.", e);
return Results.badRequest(
toJson(Throwables.getRootCause(e).getMessage()));
}
}
I tried using both Advanced REST Client in chrome and ċurl
to send the request, both failed.
What could be the problem? Could it be that I need to include a Content-Lenght
header for large requests? If so, how can I manually calculate it for arbitrary JSON data?
Please check the PlayFramework documentation, They mentionned that the default maximum length for request is 100KB: