How do I pass a bodyparameter for Rx2AndroidNetworking for get requests?

强颜欢笑 提交于 2019-12-11 12:44:05

问题


I am working on retrieving some endpoints in a helper class with Rx2AndroidNetworking. However, there is no way I can pass "addBodyParameter" with get requests (only works for post and put requests". I was wondering if there's a way around it? My postman query looks like this (which does return proper results once i add the "my_session_token" in the body as shown below: However, I am not sure how that pans out with my code. My code for retrieving it is as follows:

   @Override
    public Single<MyResponse> getMyApiCall(String userId) {
        return Rx2AndroidNetworking.get(processUrl(ApiEndPoint.MY_ENDPOINT))
                .addPathParameter("userid", userId)
                .addHeaders("Auth", mApiHeader.getFormattedProtectedApiHeader())
//I want the below line to be addBodyParameter, but doesnt work
                .addQueryParameter("my_session_token", mPreferencesHelper.getMyToken())
                .build()
                .getObjectSingle(MyResponse.class);
    }

Any idea how to go about this? Thanks!

来源:https://stackoverflow.com/questions/56244614/how-do-i-pass-a-bodyparameter-for-rx2androidnetworking-for-get-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!