这是我的代码
private void fetchDataFromServer() {
String JSON_URL = "http://example.com/www/api/v3/API.php?requestParams={ \"randohum\": \"cjjlsk\", \"ads\": [ { \"adViewId\": \"1376 \", \"isAdWall\": \"false\", \"sendRepeat\": \"false\", \"size\": \"10\", \"startIndex\": \"0\" } ], \"apiVersion\": \"3\", \"deviceLanguage\": \"en\", \"deviceX\": \"1080\", \"deviceY\": \"1776\", \"directImageUrl\": \"1\", \"subid1\": \"hello\", \"subid2\": \"how\", \"subid4\": \"you\", \"subid3\": \"are\", \"subid5\": \"fine\", \"idfa\": \"6D92078A - 8246 - 4BA4 - AW5B - 76104861E7DC\" , \"gaid\": \"d4f8030b - 4a52 - 4261 - 9830 - bd6c987cd261\", \"hashCode\": \"QEfsvgku8LSjssGSpSPNb+SissH0v878790dODTkiTAY+QO33OxEW\", \"isMobile\": \"true\", \"packageName\": \"009\",\"adWallId\":\"\",\"requestSource\":\"SDK\",\"dynamicPlacement\":\"false\" }";
StringRequest stringRequest = new StringRequest(JSON_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.v("MSG",response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.v("MSG",error.getMessage());
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
但我得到了: BasicNetwork.performRequest:意外的响应代码400。
对于没有requestParams的其他网址,它工作正常。我猜想在与volley集成时,requestParams存在一些问题。它在浏览器或邮递员中工作正常。