Stack Exchange
No response for PATCH method in Spring Boot
I'm trying to create a REST API. GET & POST method are working as expected. However for PATCH method I'm getting unexpected behaviour. Below in my controller code.
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping("v1/test")

public class TestController {

    @GetMapping(value = "get-test")
    public String getTest(){
        return "Get Success";
    }

    @PatchMapping(value = "patch-test")
    public String patchTest(){
        return "Patch Success";
    }

    @PostMapping(value = "post-test")
    public String postTest(){
        return "Post Success";
    }
}

When I hit PATCH method loader keeps spinning & not getting any response.
If I hit the PATCH after GET or POST, I get the previous API response for PATCH method.
This same code is working on other machines. I've tried with both IntelliJ & Eclipse, behaviour is same. Tried this from multiple clients like postman & curl. Attaching the screenshot. This was working previously. haven't done any changes & now it's not working

Trigger PATCH after GET


Trigger PATCH after POST


Trigger PATCH




You have two mistakes.
1- you should write "value" in the request mapping parameter as follows:
@RequestMapping(value = "v1/test")

2- you should write path instead of value in patch parameter and put / character before url as follows:
@PatchMapping(path = "/patch-test")


this is not the problem. My request is reaching patchTest() method.
Problem is I'm not getting response

Just try in simple way, this works for me within a second
Try with below code
@PatchMapping("/patchtest")
    public String patchtest(){
        return "Patch Success";
    }

Also dont forget to mention @RestController annotation
