简体   繁体   English

确定 content-type 和 content-encoding,仍然得到 415 Unsupported media type

[英]Made sure content-type and content-encoding, still get 415 Unsupported media type

In my application, I am sending request with okhttp3 and retrofit2 .在我的应用程序中,我使用okhttp3retrofit2发送请求。 Here is I logged the request by HttpLoggingInterceptor :这是我通过HttpLoggingInterceptor记录的请求:

  okhttp3.OkHttpClient: --> POST https://something/here http/1.1
  okhttp3.OkHttpClient: Content-Type: application/json; charset=UTF-8
  okhttp3.OkHttpClient: Content-Length: 2596
  okhttp3.OkHttpClient: --> END POST (2596-byte body)

And I have this in my server:我的服务器中有这个:

@Consumes("application/json; charset=UTF-8")

Currently, Keep getting HTTP 415 error code.目前,不断收到 HTTP 415 错误代码。

Environment:环境:

  • RedHat红色的帽子
  • Retrofit:2.3.0 Retrofit:2.3.0
  • Okhttp:3.8好的http:3.8
  • Logging-interceptor:3.8日志拦截器:3.8

Not only the @Produce type should match the @Consumes type, but also the @Body should be completely matched.不仅@Produce 类型应该匹配@Consumes 类型,@Body 也应该完全匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM