Easy for me! I got this a few weeks ago:
This is used in the getBody() method, and not in getParams() for the mail request.
Here is my:
@Override /** * 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(); Map<String, String> params = new HashMap<String, String>(); params.put("id","1"); params.put("name", "myname"); if (params != null && params.size() > 0) { return encodeParameters(params, getParamsEncoding()); } return null; }
(I assumed that you want POST parameters that you wrote in getParams)
I gave params a request inside the constructor, but since you create the request on the fly, you can hardcode them inside your override of the getBody () method.
This is what my code looks like:
Bundle param = new Bundle(); param.putString(HttpUtils.HTTP_CALL_TAG_KEY, tag); param.putString(HttpUtils.HTTP_CALL_PATH_KEY, url); param.putString(HttpUtils.HTTP_CALL_PARAM_KEY, params); switch (type) { case RequestType.POST: param.putInt(HttpUtils.HTTP_CALL_TYPE_KEY, RequestType.POST); SCMainActivity.mRequestQueue.add(new SCRequestPOST(Method.POST, url, this, tag, receiver, params));
and if you want even more, then the last parameters of the line come from:
param = JsonUtils.XWWWUrlEncoder.encode(new JSONObject(paramasJObj)).toString();
and paramasJObj is something like this: {"id"="1","name"="myname"} regular JSON string.
Poutrathor Nov 07 '13 at 14:08 2013-11-07 14:08
source share