BasicNetwork.performRequest:Volley的意外响应代码500 [英] BasicNetwork.performRequest: Unexpected response code 500 for Volley

查看:397
本文介绍了BasicNetwork.performRequest:Volley的意外响应代码500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建用户登录页面,我在尝试注册时遇到此错误.我想Json对象部分存在问题.我试图在论坛中搜索其他答案,但似乎都没有解决我的问题.请您帮助我.谢谢是提前.

i am trying to create a user login page, i am getting this error while i try to register.I guess there is a problem with the Json object part.I tried searching for other answers in the forum but none of seem to address my problem. Request you to help me out with this. Thanks is advance.

 public void registercheck(final String name, final String email, final String password) {
    String tag_req = "Register_request";
    pdialog.setMessage("Registering ...");
    showDialog();

    StringRequest strR = new StringRequest(Request.Method.POST, Appconfig.LOGIN_URL, new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            hidedialog();
            try {
                JSONObject jsp = new JSONObject(s);
                boolean error = jsp.getBoolean("error");
                if (!error) {
                    String uid = jsp.getString("uid");
                    JSONObject user = jsp.getJSONObject("user");
                    String name = user.getString("name");
                    String email = user.getString("email");
                    String created_at = user.getString("created_at");
                    db.addUser(name, email, uid, created_at);

                    session.setLogin(true);

                    Intent i = new Intent(Register.this, MainActivity.class);
                    startActivity(i);
                    finish();

                } else {
                    String error_msg = jsp.getString("error_msg");
                    Toast.makeText(Register.this, error_msg, Toast.LENGTH_LONG).show();

                }


            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            Log.e(TAG, volleyError.getMessage());
        }
    }) {

            @Override
        public Map<String, String> getParams() {
            Map<String, String> p = new HashMap<String, String>();
            p.put("name", name);
            p.put("tag", "register");
            p.put("email", email);
            p.put("password", password);

            return p;

我的原木猫

15.407  11021-11440/example.com.login E/Volley﹕ [2407] BasicNetwork.performRequest: Unexpected response code 500 for http://busappandroid.gear.host/

推荐答案

添加标题Content-Type-文本/html.我试图从没有标题的邮递员休息客户端调用您的api,将标题添加到api后得到错误200,结果会给出错误500

add header Content-Type - text/html. I tried to call your api from postman rest client without headers it will give error 500 after adding header to api got result 200 status ok

这篇关于BasicNetwork.performRequest:Volley的意外响应代码500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆