Search code examples
spring-mvcspring-bootspring-cloudnetflix-zuulspring-cloud-netflix

Request Method not Suported @PathVariable in @RestController in Spring


I have a RestController, now I wrote a DELETE method with @PathVariable:

@RestController("/msisdns")
public class MsisdnsController {
    @DeleteMapping("/{msisdnToUnReserve}")
    public String unreserveMsisdin(@PathVariable String msisdnToUnReserve) { ... }
}

Bult always get the same error... :

enter image description here

I´ve tried with:

@DeleteMapping("/{msisdnToUnReserve}")
public String unreserveMsisdin(@PathVariable("msisdnToUnReserve") String msisdnToUnReserve)

or

@RequestMapping(value = "/{msisdnToUnReserve}", method = RequestMethod.DELETE)
public String unreserveMsisdin(@PathVariable("msisdnToUnReserve") String msisdnToUnReserve)

and more but always the same error, I can´t reach the method

Any help?

This is my Zuul.yml, how should be trnslato URI? enter image description here

PD: /trasnlator is configured in Zuul with Spring Cloud Netflix.


Solution

  • I've experienced a similar problem when I don't specify the produces or consumes. You can try if that fixes the problem. Choose the proper type (JSON in my example):

    @DeleteMapping(value = "/{msisdnToUnReserve}", produces = org.springframework.http.MediaType#APPLICATION_JSON_VALUE)