0

I have the following RequestMapping I am testing:

@RequestMapping(value="/review", method=RequestMethod.POST)
public String reviewData( HttpServletRequest request, 
        HttpServletResponse response, 
        HttpSession session, 
        @RequestBody HashMap<String, Object> data,
        @CurrentUser User user) throws Exception {
    System.out.println("Hello World!");
}

I am testing this code expecting data to be POSTed to it from a vendor's API; which I have confirmed through their documentation andbased on conversations with their developers. Despite this I am receiving a 405 error:

Request method 'GET' not supported

I am at a lose as to the problem and am open to suggestions. I am actually wonder if the following RequestMapping would work properly to remediate this?

@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
Gedalya
  • 899
  • 4
  • 16
  • 28
  • 1
    yes it will work for both. – user Jul 01 '19 at 14:38
  • I have seen some seemingly related questions, there are more than one, and none feel like they answer my question; I should have noted that in the description. – Gedalya Jul 01 '19 at 14:38
  • 2
    I think you are not correctly POSTing the data. This error message is showing that you are sending a GET request rather than POST. – Mushif Ali Nawaz Jul 01 '19 at 14:41
  • How do you test it? maybe you do CORS request that do a preflight GET? – Boaz Jul 01 '19 at 14:42
  • I have tested it locally using a simple ajax POST and of course it works fine; the problem is that I am testing against a vendor API and I am working with their documentation and vendors and they assure me it is a POST so I am at a lose. – Gedalya Jul 01 '19 at 14:46

0 Answers0