HttpDelete with body

前端 未结 5 573
孤街浪徒
孤街浪徒 2020-11-28 08:46

I\'m attempting to use an HttpDelete object to invoke a web service\'s delete method. The web service\'s code parses JSON from the message\'s body. However, I\'m failing t

5条回答
  •  离开以前
    2020-11-28 09:03

    in retrofit

    import okhttp3.Request;
    
    private final class ApiInterceptor implements Interceptor {
    
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request oldRequest = chain.request();
            Request.Builder builder = oldRequest.newBuilder();
            if(condition) {
                return chain.proceed(builder.build().newBuilder().delete(builder.build().body()).build());
            }
            return chain.proceed(builder.build());
        }
    }
    

    you have to trigger condition, via something and potentially have to do some filtering for the url/header/body to remove the trigger,

    unless the delete url/body/header is unique enough to not collide with post or get requests.

提交回复
热议问题