Posting JSON to REST API

后端 未结 9 859
-上瘾入骨i
-上瘾入骨i 2020-12-08 08:12

I\'m creating a REST API that will accept JSON requests.

I\'m testing it out using CURL:

curl -i -POST -H \'Accept: application/json\' -d \'{\"id\":1         


        
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 09:03

    I experienced once and finally solved it by adding the jar file jackson-mapper-asl.jar. Go check if you have included all these dependencies although the exception itself does not tell u that.

    And you really don't need to explicitly configure the bean, and you don't need to put "consumes" in @RequestMapping statement. I'm using Spring 3.1 btw.

    contentType : "application/json" is the only one you need to configure. yes, client side.

提交回复
热议问题