Retrofit2 - How to execute a JSON Patch Request (RFC 6902)

Viewed 866

As of Retrofit2 2.3.0 there seems to be no built in functionality to execute a JSON Patch Request (as defined in RFC 6902. Also, see http://jsonpatch.com/ for some examples). Using the available @PATCH annotation, the full blown object is sent with the request (as if I would send a PUT request, which is not what I'm looking for)

public interface MyService {

    @PATCH("example/{id}")
    Call<Example> patchExample(@Path("id") String id, @Body Example example);

}

After a first glance at the Retrofit documentation, there seems to be no clean and easy way to introduce a custom annotation (e.g. @JSONPATCH) to have my own implementation working.

The only related information I was able to find regarding this requirement was this experimental (as he calls it himself --> this is very experimental but it does the job currently) approach at https://medium.com/@andretietz/custom-annotations-with-retrofit-2-8701ca7ce102. I didn't give this example a try, but the complexity seems a little bit out of scale for this simple requirement.

Maybe I'm missing something and there is an easy solution for this?

0 Answers
Related