在httpPost中我们使用setEntity(new StringEntity)。但我现在正在使用凌空抽射。我想在排球中使用那个setEntity方法。我怎么能这样做?
我正在尝试下面的代码:
ShZgApplication.getInstance().getRequestQueue();
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
Request.Method.POST,
Param.baseURL+"oauth",
null,
new LoginJSONResponseListener(this),
new LoginJSONResponseErrorListener(this)){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("grant_type", "password");
params.put("client_id", "shng");
params.put("client_secret", "pass");
params.put("username", username);
params.put("password", password);
return params;
}
};
ShZgApplication.getInstance().addToRequestQueue(jsonObjectRequest);
但这会产生错误:
“09-17 13:50:01.790:E / Volley(28540):[12] BasicNetwork.performRequest:http:/ url / oauth的意外响应代码500”
请帮帮我。