Hello,
I'm wondering why the body in a DELETE method still returns:
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.
as the latest update from http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#page-23
state:
Bodies on DELETE requests have no defined semantics.
Even if there is no defined semantics it doesn't forbid it.
Is there any workaround to send a delete request with a body in retrofit 2 beta-3 for the moment?
Thank you
You can use @HTTP(method = "DELETE", hasBody = true)
Thank you @JakeWharton
Also be careful linking to drafts. The text is basically the same, but be sure to look at the actual RFC: http://tools.ietf.org/html/rfc7231#section-4.3.5
Noted. My bad.
@JakeWharton I really don't want to open another bug for this, can we have this @DELETE with body relaxed. OkHttp has supported this forever, and the workaround above really hurts code generation. For example, I've got a swagger doc that has a DELETE with a body. It's really not a very RESTful protocol, but I have little say in the matter. So, now I have to figure out how to code generate slightly differently for a DELETE than I would a POST. Super painful.
Plus it's surprising to get the following:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.uk.myapp.manage, PID: 3039
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.
for method AuthenticationApi.authV1PinDeleteDelete
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752)
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:211)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.authV1PinDeleteDelete(Unknown Source)
File a new issue and I can try to look into it.
OkHttp has supported this forever
Definitely incorrect. OkHttp has not supported this forever because it
inherited the behavior from HttpURLConnection where it was mandated to
prevent a body. It probably changed late in 1.x or in 2.0 when OkHttp got
its own request/response models.
On Wed, Jan 3, 2018 at 6:45 PM Neal Sanche notifications@github.com wrote:
@JakeWharton https://github.com/jakewharton I really don't want to open
another bug for this, can we have this @delete https://github.com/delete
with body relaxed. OkHttp has supported this forever, and the workaround
above really hurts code generation. For example, I've got a swagger doc
that has a DELETE with a body. It's really not a very RESTful protocol, but
I have little say in the matter. So, now I have to figure out how to code
generate slightly differently for a DELETE than I would a POST. Super
painful.Plus it's surprising to get the following:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.uk.myapp.manage, PID: 3039
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.
for method AuthenticationApi.authV1PinDeleteDelete
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752)
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:211)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.authV1PinDeleteDelete(Unknown Source)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/1451#issuecomment-355159858,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEa0qTDCguaf9nhYzKX51TQ0WSeBSks5tHBE2gaJpZM4HAjka
.
To simplify code generation you can use @HTTP for everything. Otherwise
it's a simple if so the severity of the problem seems a bit overstated.
On Wed, Jan 3, 2018 at 9:10 PM Jake Wharton jakewharton@gmail.com wrote:
File a new issue and I can try to look into it.
OkHttp has supported this forever
Definitely incorrect. OkHttp has not supported this forever because it
inherited the behavior from HttpURLConnection where it was mandated to
prevent a body. It probably changed late in 1.x or in 2.0 when OkHttp got
its own request/response models.On Wed, Jan 3, 2018 at 6:45 PM Neal Sanche notifications@github.com
wrote:@JakeWharton https://github.com/jakewharton I really don't want to
open another bug for this, can we have this @delete
https://github.com/delete with body relaxed. OkHttp has supported this
forever, and the workaround above really hurts code generation. For
example, I've got a swagger doc that has a DELETE with a body. It's really
not a very RESTful protocol, but I have little say in the matter. So, now I
have to figure out how to code generate slightly differently for a DELETE
than I would a POST. Super painful.Plus it's surprising to get the following:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.uk.myapp.manage, PID: 3039
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.
for method AuthenticationApi.authV1PinDeleteDelete
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752)
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:211)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.authV1PinDeleteDelete(Unknown Source)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/1451#issuecomment-355159858,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEa0qTDCguaf9nhYzKX51TQ0WSeBSks5tHBE2gaJpZM4HAjka
.
Then the problem actually commutes to the GET which doesn't accept a body.
Thanks for the consideration, I'll open another issue.
I also agree, forever is a much longer time than I should have indicated.
On Wed, Jan 3, 2018, 7:12 PM Jake Wharton notifications@github.com wrote:
To simplify code generation you can use @HTTP for everything. Otherwise
it's a simpleifso the severity of the problem seems a bit overstated.On Wed, Jan 3, 2018 at 9:10 PM Jake Wharton jakewharton@gmail.com wrote:
File a new issue and I can try to look into it.
OkHttp has supported this forever
Definitely incorrect. OkHttp has not supported this forever because it
inherited the behavior from HttpURLConnection where it was mandated to
prevent a body. It probably changed late in 1.x or in 2.0 when OkHttp got
its own request/response models.On Wed, Jan 3, 2018 at 6:45 PM Neal Sanche notifications@github.com
wrote:@JakeWharton https://github.com/jakewharton I really don't want to
open another bug for this, can we have this @delete
https://github.com/delete with body relaxed. OkHttp has supported
this
forever, and the workaround above really hurts code generation. For
example, I've got a swagger doc that has a DELETE with a body. It's
really
not a very RESTful protocol, but I have little say in the matter. So,
now I
have to figure out how to code generate slightly differently for a
DELETE
than I would a POST. Super painful.Plus it's surprising to get the following:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.uk.myapp.manage, PID: 3039
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain
@Body.
for method AuthenticationApi.authV1PinDeleteDelete
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752)
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:211)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.authV1PinDeleteDelete(Unknown Source)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/square/retrofit/issues/1451#issuecomment-355159858
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AAEEEa0qTDCguaf9nhYzKX51TQ0WSeBSks5tHBE2gaJpZM4HAjka.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/1451#issuecomment-355181142,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFHsyZOHM2qAu0SjrK9mYifqnZjFkyQqks5tHDNzgaJpZM4HAjka
.>
Neal Sanche
Android Tech Lead
mobile: 403.870.2356 <+14038702356>
robotsandpencils.com http://robotsandpencils.com/
--
Robots and Pencils Inc | 1507 14th Ave SW Calgary AB T3C 0W4
You can unsubscribe from the Robots and Pencils mailing lists by clicking
here. https://robotsandpencils.com/contact/unsubscribe.html
You can use
@HTTP(method = "DELETE", hasBody = true)
@JakeWharton
This workaround is throwing an error for me:
"retrofit.RetrofitError: UserService.delete: HTTP method annotation is required (e.g., @GET, @POST, etc.)."
Please submit a failing test case or sample that reproduces in a new issue.
Most helpful comment
You can use
@HTTP(method = "DELETE", hasBody = true)