简体   繁体   English

没有得到URL的排球响应,但在邮递员工作

[英]Not getting response from URL in volley but working in postman

Introduction - 介绍 -

I am trying to get json response from a external url. 我试图从外部网址获取json响应。 it does not require any special auth or header. 它不需要任何特殊的身份验证或标头。 we can just put it on as a url in web browser and get the response. 我们可以把它作为网页浏览器中的URL并获得响应。 but i am getting error in volley jsonrequest. 但是我在凌空jsonrequest中遇到错误。

URL - https://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/niftyStockWatch.json 网址 - https://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/niftyStockWatch.json

Error i am getting in Volley - 我在Volley中遇到错误 -

com.android.volley.AuthFailureError com.android.volley.AuthFailureError

Volley Request - 排球请求 -

JsonObjectRequest jsonObjectRequest =
new JsonObjectRequest(Request.Method.GET,
                      "https://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/niftyStockWatch.json",
                      null,
                      new Response.Listener<JSONObject>() {
                         @Override
                         public void onResponse(JSONObject response) {
                         Log.i("TAG","response : " + response);
                         }
                      },
                      new Response.ErrorListener() {
                         @Override
                         public void onErrorResponse(VolleyError error) {
                         Log.i("TAG","error : " + error);
                         }
                      });
queue.add(jsonObjectRequest);

Edit - 编辑 -

The GET Request code that is being sent in Postman is - 邮递员发送的GET请求代码是 -

GET
/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json HTTP/1.1
Host: www.nseindia.com
Cache-Control: no-cache
Postman-Token: 6fd9baa2-9313-a592-fff4-445b3c5e25d2

This might be helpful to suggest me why i am unable to get the same response in volley as in postman. 这可能有助于建议我为什么我无法在邮差中得到同样的回应。

I was wandering as i just put a GET request in postman with the URL, i get the response. 我徘徊,因为我只是在邮递员的URL中提出GET请求,我得到了答复。 but why i am not getting same response from the volley ? 但为什么我没有得到同样的反应?

You inserted this tag on AndroidManifest.xml? 您是否在AndroidManifest.xml上插入了此标记?

<uses-permission android:name="android.permission.INTERNET" />

If not, insert it and try again. 如果没有,请插入并重试。

if yes, your request headers on postman is the SAME on volley ? 如果是的话,邮递员的请求标题是凌空的同一个?

Please post your request headers from volley for more information. 请从volley发布您的请求标题以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM