415 Unsupported MediaType for POST request in spring application

前端 未结 3 1278
广开言路
广开言路 2020-12-06 10:59

I have a very simple Spring Application (NOT spring boot). I have implemented a GET and POST controller methods. the GET method works fine. But the

3条回答
  •  伪装坚强ぢ
    2020-12-06 11:20

    can you trying using the -d option in curl

    curl -H "Content-Type: application/json" -X POST -d
     '{"id":"1,"name":"sai"}'
     http://localhost:8095/myApp/service/example/sample2
    

    Also, if you use windows you should escape double quotes

    -d "{ \"id\": 1, \"name\":\"sai\" }" 
    

提交回复
热议问题