Error from Call Rest service

0
Hi, I tried creating a java action to Escape the parameter to prevent the ACR Security violation (REST calls with templates should be escaped) When I used the java action in our application, I got an error from the POST Call Rest Service {"error":{"code":"INTERNAL_SERVER_ERROR","message":{"lang":"en","value":"Illegal argument for method call with message 'value'."}}} This is the Sample payload I sent to java action {"Attribute":"1","Attribute1":"5678","Attribute3":"1"} This is the output of the java action {"Attribute":"1","Attribute1":"5678","Attribute3":"1"} Java action code- if (PayloadJSON==null)              return JsonNull.INSTANCE.toString();         JsonPrimitive jp = new JsonPrimitive(PayloadJSON); // this does the escaping!         String JavaEscape = jp.toString(); // do not use getAsString as it unescapes.         String JavaEscaped= JavaEscape.substring(1, JavaEscape.length()-1);         String Payload= JavaEscaped.replace("\\","");         return Payload; This is mainly focusing on the Solving the ACR violation. Please help with the issue or let me know if there is any Other solution.    Thank you  
asked
2 answers
0

Hi,

This is the request body of the Rest Call.

answered
0

You could just make your template

{1}

Then you can pass in the raw JSON string without having to worry about trying to do any escaping in Java.

It may be easier to just use an Export Mapping though if your JSON is always in the same format.
https://docs.mendix.com/refguide/call-rest-action/#61-export-mapping-for-the-entire-request
 

I hope this helps.

answered