[英]AndroidVolley - Unexpected response code 500
Accessing a specific WEB-service using postman (a chrome extension for testing WEB services) results in a successful response, but my application implementation fails at hitting the same WEB-service and reports the following error: 使用邮递员(用于测试WEB服务的chrome扩展程序)访问特定的WEB服务会导致成功的响应,但是我的应用程序实现无法访问相同的WEB服务并报告以下错误:
E/Volley: [365] BasicNetwork.performRequest: Unexpected response code 500 for link I'm using E / Volley:[365] BasicNetwork.performRequest:我正在使用的链接的意外响应代码500
What am I missing here? 我在这里想念什么?
Thank you. 谢谢。
My application code: 我的应用程序代码:
private void Uploads(final String imagePath)
{
CustomJSONObjectRequest rq = new CustomJSONObjectRequest(Request.Method.POST, BASE_URL, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
String success = response.getString("message");
Toast.makeText(getActivity(), success, Toast.LENGTH_LONG).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("Response Error", error.toString());
Toast.makeText(getActivity(), "Fail", Toast.LENGTH_LONG).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<>();
headers.put("token", "$2y$10$2V.Ux6CRmHoPCs2UziaVx.e6poDbFkZE2rrGrrLO1YbGcuUnkGFSS");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("email", "t@t.ru");
params.put("name", "Abyl");
params.put("phone", "7777777777");
params.put("fio", "fioasiodfaisfoiaosf");
params.put("zarplata_ot", "450000");
params.put("zarplata_do", "800000");
params.put("opit_raboty", "2");
params.put("city_id", "1");
params.put("img",imagePath);
params.put("user_id", "73");
params.put("description", "asdasdasdasdasdasdasdasd");
return params;
}
};
VolleyController.getInstance(getActivity()).addToRequestQueue(rq);
}
If you're using Volley , you have to check some of the basic configuration . 如果您使用的是Volley,则必须检查一些基本配置。 So 所以
Make sure , You initialize this Appcontroller in your Android Manifest.like this. 确保,您可以在Android Manifest中初始化此Appcontroller。
<application android:name="app.AppController" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
Print your params hashmap , your token and your stacktrace also .it'll help you to identify your problem in deep and check your Baseurl once again 同时打印您的参数哈希图 , 令牌和stacktrace。它将帮助您深入识别问题并再次检查Baseurl
Code 500 is a HTTP Error Code that means "Internal Server Error". 代码500是HTTP错误代码,表示“内部服务器错误”。 So, probably the problem stays on your API's side 因此,问题可能出在您的API一边
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.