orhanobut / wasp

Compact and easy to use, 'all-in-one' android network solution
Apache License 2.0
584 stars 71 forks source link

How to add multiple params on interceptors onQueryParamsAdded (solved) #136

Open cutiko opened 8 years ago

cutiko commented 8 years ago

EDIT: This is working perfectly I was misslead by the backend response, please dont take this in consideration. Thanks for your time and sorry for such naive mistake.


I want to add multiple params on the interceptor, for some reason the only param added is the first, this is my code:

public MyService getService(Context context){
        String SESSION_KEY = 109huj1293u2;
        String DEVICE_ID = 10293ud1312a;
        String TIME_STAMP = 123451;

        MyService service = new Wasp.Builder(context).setEndpoint("http://someurl.com/api").setRequestInterceptor(new RequestInterceptor() {
            @Override
            public void onHeadersAdded(Map<String, String> headers) {
            }
            @Override
            public void onQueryParamsAdded(Map<String, Object> params) {
               //HERE IS MY PROBLEM, only SESSION_KEY is working
                params.put("session_key",SESSION_KEY);
                params.put("timestamp", TIME_STAMP);
                params.put("device_id", DEVICE_ID);
            }

            @Override
            public WaspRetryPolicy getRetryPolicy() {
                return null;
            }

            @Override
            public AuthToken getAuthToken() {
                return null;
            }
        }).build().create(MyService.class);
        return service;
    }

I have trimmed down some of the code, but I think this should be enough. I know this is working cause if I use a rest manager (by example a G. Chrome extension) works fine.

Am I doing something wrong?

orhanobut commented 8 years ago

glad to see it is already working, was away to check the issues.