I am issuing a POST request from my Angular 8 Liferay 7.3 Portlet and trying to get its contents in the serveResource
method in the MVCResourceCommand
class.
The frontend JS looks like this:
submit() {
let message = {
type: "form",
body: this.model
};
this.http.post<any>("http://my/url", message).subscribe(response => {
console.log(JSON.stringify(response));
})
}
The meesage hits the endpoint, so the backend is well configured.
Based on this, this and this I have also set the "com.liferay.portlet.requires-namespaced-parameters=false"
property in order namespaces not to be an issue - so, basically, every point in the check list is done and the request body should be accessible.
Every post I read so far is talking about getting the request info with ParamUtil.getString(uploadRequest, "text");
, but I am not sure how this should work if the body is a JSON object - I mean, how should I retrieve the value if the POST body looks like this:
{
"firstVal": "abc",
"secondVal": "def",
"another": {
"objectVal1": 1,
"objectVal2": 2
}
}