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

前端 未结 13 1855
渐次进展
渐次进展 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:34

    Just in case this is helpful to others, here's my anecdote:

    I found this thread as a result of a problem I encountered while I was using Postman to send test data to my RESTEasy server, where- after a significant code change- I was getting nothing but 415 Unsupported Media Type errors.

    Long story short, I tore everything out, eventually I tried to run the trivial file upload example I knew worked; it didn't. That's when I realized that the problem was with my Postman request. I normally don't send any special headers, but in a previous test I had added a "Content-Type": "application/json" header. OF COURSE, I was trying to upload "multipart/form-data." Removing it solved my issue.

    Moral: Check your headers before you blow up your world. ;)

提交回复
热议问题