Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML

前端 未结 13 1856
渐次进展
渐次进展 2020-11-27 04:57

I am actually new to REST WS but really I don\'t get this 415 Unsupported Media Type.

I am testing my REST with Poster on Firefox and the GET

13条回答
  •  清酒与你
    2020-11-27 05:50

    I had the same problem:

    curl -v -H "Content-Type: application/json" -X PUT -d '{"name":"json","surname":"gson","married":true,"age":32,"salary":123,"hasCar":true,"childs":["serkan","volkan","aybars"]}' XXXXXX/ponyo/UserModel/json

    * About to connect() to localhost port 8081 (#0)
    *   Trying ::1...
    * Connection refused
    *   Trying 127.0.0.1...
    * connected
    * Connected to localhost (127.0.0.1) port 8081 (#0)
    > PUT /ponyo/UserModel/json HTTP/1.1
    > User-Agent: curl/7.28.1
    > Host: localhost:8081
    > Accept: */*
    > Content-Type: application/json
    > Content-Length: 121
    > 
    * upload completely sent off: 121 out of 121 bytes
    < HTTP/1.1 415 Unsupported Media Type
    < Content-Type: text/html; charset=iso-8859-1
    < Date: Wed, 09 Apr 2014 13:55:43 GMT
    < Content-Length: 0
    < 
    * Connection #0 to host localhost left intact
    * Closing connection #0
    

    I resolved it by adding the dependency to pom.xml as follows. Please try it.

        
            com.owlike
            genson
            0.98
        
    

提交回复
热议问题