sending volley request with nested hashmap parameters

痞子三分冷 提交于 2019-12-12 05:54:28

问题


i am using android volley framework for sending jsonobject request to my server.get request is working fine.now i would like to send a post request with request parameters which is nested hashmap< string,object >.i override the getparams method but it expects me to send hashmap< string,string >.

there is any way to pass hashmap as request parameter?

i have followed this link enter link description here


回答1:


try override below method, it is from source code:

/**
 * Returns the raw POST or PUT body to be sent.
 *
 * @throws AuthFailureError in the event of auth failure
 */
public byte[] getBody() throws AuthFailureError {
    Map<String, String> params = getParams();
    if (params != null && params.size() > 0) {
        return encodeParameters(params, getParamsEncoding());
    }
    return null;
}

Returns the raw POST or PUT body to be sent.

so override the getBody() with your parameter.




回答2:


You can use the getParamsEncoding in override method getBody().

Here, this link will help you.



来源:https://stackoverflow.com/questions/27561421/sending-volley-request-with-nested-hashmap-parameters

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