[英]Volley BasicNetwork.performRequest: Unexpected response code 301
Hello I am having a problem.你好我有问题。 I am using Volley to request to https://swapi.dev/我正在使用 Volley 向https://swapi.dev/请求
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Request.Method.GET,
"http://swapi.dev/api/planets/1/",
System.out::println,
null);
queue.add(request);
Then Volley throws an exception:然后 Volley 抛出异常:
E/Volley: [53530] BasicNetwork.performRequest: Unexpected response code 301 for http://swapi.dev/api/planets/1/
Please help请帮忙
You are using this url:您正在使用此 url:
http://swapi.dev/api/planets/1/
Enable "ClearText" compatibility to allow connections using http:
, this must be done inside your AndroidManifest.xml
file:启用“ClearText”兼容性以允许使用http:
进行连接,这必须在您的AndroidManifest.xml
文件中完成:
<application
...
....
android:usesCleartextTraffic="true"
...
...
Is recommended to use only https://
like https://swapi.dev/api/planets/1/
建议仅使用https://
像https://swapi.dev/api/planets/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.