从Rest客户端成功获取400凌空服务器错误

kon*_*dal 2 android yahoo-api yahoo-finance android-volley

对于以下网址的排球获取请求,我得到400服务器错误

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ('AEDALL')&format=json&env=store://datatables.org/alltableswithkeys&callback=
Run Code Online (Sandbox Code Playgroud)

当我从休息客户端点击相同的URL时,它给出了json响应

这是我的截击请求代码

private void convertCurrenctVolleyTask(String from, final String to, final String amount) {

    String url_yahoo = "http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ('"+from+to+"')&format=json&env=store://datatables.org/alltableswithkeys&callback=";

    final ProgressDialog progressDialog;
    progressDialog = new ProgressDialog(CurrencyConverter.this);
    progressDialog.setMessage("Please wait...");
    progressDialog.setCancelable(true);
    progressDialog.show();

    JsonObjectRequest GetCurrenciesjsObjRequest = new JsonObjectRequest(
            Request.Method.GET, url_yahoo, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    progressDialog.cancel();
                    if (response != null) {
                            parseGetCurrencyResp(response,to,amount);

                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    progressDialog.cancel();
                    Toast.makeText(CurrencyConverter.this,
                            "Server error..", Toast.LENGTH_SHORT).show();
                    error.printStackTrace();

                }
            });

    ConfigVolley.getInstance().addToRequestQueue(GetCurrenciesjsObjRequest);

}
Run Code Online (Sandbox Code Playgroud)

任何帮助赞赏

小智 8

您将需要用%20 url_yahoo = url_yahoo.replace("","%20")替换所有出现的空格("");