I would like to always add a parameter to my re-settings. For values ββthat I can hard code, I can just use
@POST("/myApi?myParam=myValue")
but what if i want to add android.os.Build.MODEL ?
@POST("/myApi?machineName="+ Build.MODEL)
does not work. It would be useful to be able to distract this part of the network call from the implementing code.
EDIT
I can add Build.MODEL to all my api calls using RequestInterceptor . However, it still eludes me, how to add it selectively only to some of my api calls, but it uses the same RestAdapter .
EDIT 2
Fixed header that was incorrect.
EDIT 3
Current implementation:
RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("myapi") .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestInterceptor.RequestFacade request) { request.addQueryParam("machineName", Build.MODEL); } }) .build(); API_SERVICE = restAdapter.create(ApiService.class);
source share