My api expects an empty json body ({ }
) when making post requests. How do I set this up in Retrofit and Jackson?
I tried passing null
, and empty string, and "{}"
but could not get this to work.
@POST(my/url)
Call<MyResponse> createPostRequest(@Body Object empty);
How can I set an empty JSON body?
Empty class will do the trick:
class EmptyRequest {
public static final EmptyRequest INSTANCE = new EmptyRequest();
}
interface My Service {
@POST("my/url")
Call<MyResponse> createPostRequest(@Body EmptyRequest request);
}
myService.createPostRequest(EmptyRequest.INSTANCE);