Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 带有参数的get请求出现截击错误(意外响应代码400)_Android_Json_Http_Android Volley - Fatal编程技术网

Android 带有参数的get请求出现截击错误(意外响应代码400)

Android 带有参数的get请求出现截击错误(意外响应代码400),android,json,http,android-volley,Android,Json,Http,Android Volley,这是我的密码 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\",

这是我的密码

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);
private void fetchDataFromServer(){
字符串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\”:“DirectURL\”,“Device\“1.1\”,“1.1\”,“1.1\”,“subid2\”:“如何”以及“如何”如何,“subid4\”,“subid4\”:“你们们\”,“subid3\”:“你们们\”,“1.1\”,“1.1\”,“1.1\”、“1.1\”,“subid4\”,“你们们\”,“你们们\”,“你们们\”,“你们们\”,“你们们\”,“你们们\”,“你们们\”,“subid3\”:::“你们们\”,“你们们\”,“你们们\”,“你们们\”,“你们们\”,“你们们\”,,“你们们\”,“你们们\”,“你们们\”,“你们们\”,,,,,,,“你们们\”,,“你们们3\”,“你们们们们isMobile\:“true\”\“packageName\”:“009\”,“adWallId\”:“\”,“requestSource\”:“SDK\”,“DynamicLocation\”:“false\”};
StringRequest StringRequest=新的StringRequest(JSON_URL,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
Log.v(“MSG”,响应);
}
},
新的Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
Log.v(“MSG”,error.getMessage());
}
});
RequestQueue RequestQueue=Volley.newRequestQueue(this);
添加(stringRequest);
但我得到了: BasicNetwork.performRequest:意外响应代码400


对于没有requestParams的其他url,它工作正常。我想当与volley集成时,requestParams可能会出现一些问题。它在浏览器或邮递员中工作正常。

为什么要将
requestParams
放在url中?这看起来是错误的…这是一个GET请求,有一个参数。关键是“requestParams”但为什么?把json放到GET请求中似乎是一个糟糕的API设计…而且URL中也不能有空格…你确定这不是POST请求吗?你能展示一下它在POSTman中工作的屏幕截图吗?