Custom Delete Method with Retrofit 2.0
See original GitHub issueAccoring to @JakeWharton it is possible to overwrite Rest Methods. I need a customized method (DELETE with Body) as it isn´t allowed by retrofit even if it´s allowed by rfc spec. But this does not work anyore since the Annotation @RestMethod was removed since retrofit 2.0 So how can I send now a HTTP-DELETE with Body?
see alsow: https://github.com/square/retrofit/issues/426 and https://github.com/square/okhttp/issues/605
If I use default mechnism of retrofit 2.0 i get a stacktrace
@DELETE("/myurl")
Call<String> deactivateUserPermanently(
@Header("Authorization") String systemAuthLine,
@Body MyBodyRequest myBodyRequest
);
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.
for method MyProxy.deactivateUserPermanently
at retrofit.Utils.methodError(Utils.java:177)
at retrofit.Utils.methodError(Utils.java:167)
at retrofit.RequestFactoryParser.parseParameters(RequestFactoryParser.java:359)
at retrofit.RequestFactoryParser.parse(RequestFactoryParser.java:60)
at retrofit.MethodHandler.create(MethodHandler.java:30)
at retrofit.Retrofit.loadMethodHandler(Retrofit.java:151)
at retrofit.Retrofit$1.invoke(Retrofit.java:132)
at com.sun.proxy.$Proxy7.deactivateUserPermanently(Unknown Source)
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Retrofit 2.0 how to delete? - java - Stack Overflow
Do it this way as you noted last: Call<ResponseBody> deleteBook(@Path("id") int bookId);. Make sure you make the call off the UI-thread via ...
Read more >Retrofit 2 — How to Delete Objects on the Server - Future Studio
Summary. In this tutorial you've learned how to delete objects on the server. Deleting objects is quite easy with the DELETE HTTP method....
Read more >Remove Resource in server: Android Retrofit in Kotlin #5.4
... 60 days FREE: https://pluralsight.pxf.io/c/1291657/424552/7490 Retrofit Android using Kotlin. Learn to perform HTTP DELETE request a...
Read more >HTTP (Retrofit 2.7.1 API)
Use a custom HTTP verb for a request. interface Service { @HTTP(method = "CUSTOM", path = "custom/endpoint/") Call<ResponseBody> customEndpoint(); }
Read more >Retrofit Android Example Tutorial - DigitalOcean
The getClient() method in the above code will be called every time while setting up a Retrofit interface. Retrofit provides with a list...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually, the correct syntax is: @HTTP(method = “DELETE”, path = “/foo”, hasBody = true)
@Zhuinden This is correct one. interface Example { @HTTP(method = “DELETE”, path = “/foo, hasBody = true”) Call method(); }