There seems to be an issue regarding the addition of parameters in the Execution context when I am interacting with Moqui using AngularJS.
The content-type of the request header is automatically set to application/json; charset=UTF-8
. But the code in the WebFacadeImpl.groovy
for handling application/json
requests is
String contentType = request.getHeader("Content-Type")
if (contentType == "application/json" || contentType == "text/json" || contentType.matches("(.*)application/json(.*)")) {
JsonSlurper slurper = new JsonSlurper()
Object jsonObj = null
try {
jsonObj = slurper.parse(new BufferedReader(new InputStreamReader(request.getInputStream(),
request.getCharacterEncoding() ?: "UTF-8")))
} catch (Throwable t) {
logger.error("Error parsing HTTP request body JSON: ${t.toString()}", t)
jsonParameters = [_requestBodyJsonParseError:t.getMessage()]
}
if (jsonObj instanceof Map) {
jsonParameters = (Map<String, Object>) jsonObj
} else if (jsonObj instanceof List) {
jsonParameters = [_requestBodyJsonList:jsonObj]
}
// logger.warn("=========== Got JSON HTTP request body: ${jsonParameters}")
}
This code does not consider the case when the Content-Type is set to application/json; charset=UTF-8
and the parameters are not added to the context automatically.
Shouldn't there be a condition that checks for application/json
as a substring for the content-type?