简体   繁体   English

java.net.ProtocolException:HTTP方法DELETE不支持输出

[英]java.net.ProtocolException: HTTP method DELETE doesn't support output

I am having this error while using jersey-client-1.19 . 使用jersey-client-1.19时出现此错误。 All the googling I have done points to a bug or unnecessary limitation in HttpUrlConnection, especially in java 7 . 我所做的所有搜索都指向HttpUrlConnection中的错误或不必要的限制,尤其是在java 7

I have been advised by some to move to java 8, I am not ready for that now. 有人建议我改用Java 8,但现在还没有准备好。

I have already heard suggestions of transferring all my parameters to path but this can not work for me as the API requires me to pass certain authentication details as a json request body. 我已经听说过将所有参数传输到path的建议,但这对我来说不起作用,因为API要求我将某些身份验证详细信息作为json请求正文传递。

I have already looked at several answers related to this question including How do Jersey-client and Apache HTTP Client compare? 我已经查看了与该问题相关的几个答案,包括Jersey-client和Apache HTTP Client的比较如何? . which suggests explicitely defining Apache's httpclient for jersey . 这建议为jersey明确定义Apache的httpclient。 So I thought there should be a standard integration of jersey-client-1.19 with Apache httpclient in the back which is indeed confirmed by Paul Sandoz answer . 因此,我认为应该在背面将jersey-client-1.19与Apache httpclient进行标准集成,这确实得到Paul Sandoz answer的确认。 However all the links he has offered there are down. 但是,他在此处提供的所有链接都已断开。

Does anyone know of any such integration or alternatively how I can just resolve this issue? 有谁知道任何这种集成,或者我怎么能解决这个问题?

For anyone who still faces this problem, I am adding the hot-fix that worked for me. 对于仍然面临此问题的任何人,我都会添加对我有用的修复程序。 Basically, we resolved to send HTTP DELETE requests as POST to enable us to add a request body, with an additional {"delete":true} field in the JSON body. 基本上,我们决定将HTTP DELETE请求作为POST发送,以使我们能够添加请求正文,并在JSON正文中带有一个额外的{"delete":true}字段。 This will only work if it is the same team that is working on the REST service or if you are in position to add the corresponding check in the backend. 仅当使用REST服务的团队是同一团队,或者您可以在后端中添加相应的支票时,这才起作用。

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

相关问题 java.net.ProtocolException: 方法不支持请求正文:GET - java.net.ProtocolException: method does not support a request body: GET java.net.ProtocolException:读取输入后无法写入输出 - java.net.ProtocolException: Cannot write output after reading input 改进:java.net.ProtocolException:未知方法“ PATCH” - Retrofit: java.net.ProtocolException: Unknown method 'PATCH' android中带有HttpsURLConnection的java.net.protocolException - java.net.protocolException with HttpsURLConnection in android java.net.ProtocolException:重定向过多:21 Android 应用 - java.net.ProtocolException: Too many redirects: 21 Android App java.net.ProtocolException:在哪里读取输入? - java.net.ProtocolException: where is input being read? MediaHTTPConnection:readAt 3110239/32768 => java.net.ProtocolException错误 - MediaHTTPConnection: readAt 3110239 / 32768 => java.net.ProtocolException Error android java.net.ProtocolException:已建立连接 - android java.net.ProtocolException: Connection already established java.net.ProtocolException: 服务器重定向次数过多 (20) - java.net.ProtocolException: Server redirected too many times (20) 改造“java.net.ProtocolException:意外的状态行”,任何人? - Retrofit “java.net.ProtocolException: Unexpected status line”, Anyone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM