Skip to Content
1
Former Member
Jul 22, 2015 at 01:29 PM

JSON & CSRFToken using POST problems

1130 Views

Hi,

I have this action in my controller:

 @RequestMapping(value = "/returnRequest", method = RequestMethod.POST)
     public String createReturnRequest(@RequestBody final PuntRomaReturnRequestForm bodyParameterMap, final Model model,
             final BindingResult bindingErrors)
     {
         return null
     }

And I had to use this ugly Javascript code to make possible to parse the JSON object to my Data Object

 $.ajax({
   type : 'POST',
   url : "https://localhost:9002/ES/es/my-account/returnRequest?CSRFToken=" + ACC.config.CSRFToken,
   contentType : "application/json",
   data : JSON.stringify({
     code: "00018001",
 })
  });

Plus, automagically the CSRFToken is also added to my JSON object.

What is the standard way in hybris to make post of JSON objects without the necessity of add as param the CSRFToken? Also, how can I avoid CSRFToken to be inserted in the data object?

Thanks!