How to enable @RequestMapping to work independently for Patch and Post method with specific header?

38 Views Asked by At

We are exposing an http **PATCH ** operation for our consumers, Who are using it with HttpMethod:POST and X-Http-method-override:PATCH now we have shifted it to Spring boot where in we have to enable this(to provide backward compatiblity) and allow the direct access of PATCH operation also, without above header.

But while trying to access direct HTTP PATCH methods from postman using:

http://localhost:8080/myApp/services/recordInventory/v2/record/republication

I have used below code but its not working.

**code sample : **

@RequestMapping(value="/v2/product/republication", method= RequestMethod.POST, headers = {"X-HTTP-Method-Override=PATCH"}, produces=MediaType.APPLICATION_JSON_VALUE)
@PatchMapping(value="/v2/product/republication", produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> republication() throws CIBTechnicalException, CIBException;

with above i am getting:

Response-Code: 405
Content-Type: null
Headers: {Allow=GET,POST,PUT}
0

There are 0 best solutions below