Android 运行api时,会显示内部服务器错误 公共类材质支持API扩展异步任务{ @凌驾 受保护的字符串doInBackground(字符串…参数){ MaterialJson JSONOBJECT=新MaterialJson(); name=(EditText)findViewById(R.id.edt_name); mobile=(EditText)findViewById(R.id.edt\U联系人号码); street=(EditText)findViewById(R.id.edt_地址1); city=(EditText)findViewById(R.id.edt_地址2); 状态=(EditText)findViewById(R.id.edt_地址3); zipcode=(EditText)findViewById(R.id.edt_地址4); day=(喷丝器)findViewById(R.id.喷丝器1_天); 月=(喷丝器)findViewById(R.id.喷丝器2_月); time_from=(微调器)findViewById(R.id.spinner3_time_from); 时间到=(微调器)findViewById(R.id.spinner4到时间); setName(name.getText().toString()); setMobile(mobile.getText().toString()); JSONOBJECT.setStreet(street.getText().toString()); setCity(city.getText().toString()); setState(state.getText().toString()); setZipcode(zipcode.getText().toString()); JSONOBJECT.setDay(day.getSelectedItem().toString()); JSONOBJECT.setMonth(month.getSelectedItem().toString()); JSONOBJECT.setTimeFrom(time_from.getSelectedItem().toString()); JSONOBJECT.setTimeTo(time_to.getSelectedItem().toString()); JSONObject obj=新的JSONObject(); 试一试{ put(“name”,JSONOBJECT.getName()); put(“mobile”,JSONOBJECT.getMobile()); 对象put(“day”,JSONOBJECT.getDay()); 对象put(“month”,JSONOBJECT.getMonth()); put(“time_from”,JSONOBJECT.getTimeFrom()); put(“time_to”,JSONOBJECT.getTimeTo()); 对象put(“street”,JSONOBJECT.getStreet()); object.put(“city”,JSONOBJECT.getCity()); put(“state”,JSONOBJECT.getState()); put(“zipcode”,JSONOBJECT.getZipcode()); //put(“type”,JSONOBJECT.getType()); }捕获(JSONException e){ e、 printStackTrace(); } //Toast.makeText(this,obj.toString(),Toast.LENGTH_LONG).show(); DefaultHttpClient httpclient=新的DefaultHttpClient(); HttpPost httput=新的HttpPost(“https://vaananba.herokuapp.com/api/materialsupport"); StringEntity se=null; 试一试{ se=新的StringEntity(obj.toString()); }捕获(不支持的编码异常e){ e、 printStackTrace(); } httput.setEntity(se); setHeader(“内容类型”、“应用程序/json”); int a=0; 试一试{ HttpResponse resp=httpclient.execute(httput); /*a=相应的getStatusLine().getStatusCode(); 返回a*/ String ResponseBy=EntityUtils.toString(resp.getEntity()); //a=相应的getStatusLine().getStatusCode(); 返回responseBody.toString(); }捕获(IOE异常){ e、 printStackTrace(); } 返回null; } @凌驾 受保护的void onPostExecute(字符串结果){ //TextView aa=(TextView)findViewById(R.id.textView3); //aa.setText(结果); //按钮提交=(按钮)findViewById(R.id.btn\u iamsupport); //submit.setText(结果); Toast.makeText(MaterialSupport.this,result,Toast.LENGTH_LONG.show(); //Toast.makeText(IamSupport.this,result,Toast.LENGTH_LONG).show(); } @凌驾 受保护的void onPreExecute(){} }

Android 运行api时,会显示内部服务器错误 公共类材质支持API扩展异步任务{ @凌驾 受保护的字符串doInBackground(字符串…参数){ MaterialJson JSONOBJECT=新MaterialJson(); name=(EditText)findViewById(R.id.edt_name); mobile=(EditText)findViewById(R.id.edt\U联系人号码); street=(EditText)findViewById(R.id.edt_地址1); city=(EditText)findViewById(R.id.edt_地址2); 状态=(EditText)findViewById(R.id.edt_地址3); zipcode=(EditText)findViewById(R.id.edt_地址4); day=(喷丝器)findViewById(R.id.喷丝器1_天); 月=(喷丝器)findViewById(R.id.喷丝器2_月); time_from=(微调器)findViewById(R.id.spinner3_time_from); 时间到=(微调器)findViewById(R.id.spinner4到时间); setName(name.getText().toString()); setMobile(mobile.getText().toString()); JSONOBJECT.setStreet(street.getText().toString()); setCity(city.getText().toString()); setState(state.getText().toString()); setZipcode(zipcode.getText().toString()); JSONOBJECT.setDay(day.getSelectedItem().toString()); JSONOBJECT.setMonth(month.getSelectedItem().toString()); JSONOBJECT.setTimeFrom(time_from.getSelectedItem().toString()); JSONOBJECT.setTimeTo(time_to.getSelectedItem().toString()); JSONObject obj=新的JSONObject(); 试一试{ put(“name”,JSONOBJECT.getName()); put(“mobile”,JSONOBJECT.getMobile()); 对象put(“day”,JSONOBJECT.getDay()); 对象put(“month”,JSONOBJECT.getMonth()); put(“time_from”,JSONOBJECT.getTimeFrom()); put(“time_to”,JSONOBJECT.getTimeTo()); 对象put(“street”,JSONOBJECT.getStreet()); object.put(“city”,JSONOBJECT.getCity()); put(“state”,JSONOBJECT.getState()); put(“zipcode”,JSONOBJECT.getZipcode()); //put(“type”,JSONOBJECT.getType()); }捕获(JSONException e){ e、 printStackTrace(); } //Toast.makeText(this,obj.toString(),Toast.LENGTH_LONG).show(); DefaultHttpClient httpclient=新的DefaultHttpClient(); HttpPost httput=新的HttpPost(“https://vaananba.herokuapp.com/api/materialsupport"); StringEntity se=null; 试一试{ se=新的StringEntity(obj.toString()); }捕获(不支持的编码异常e){ e、 printStackTrace(); } httput.setEntity(se); setHeader(“内容类型”、“应用程序/json”); int a=0; 试一试{ HttpResponse resp=httpclient.execute(httput); /*a=相应的getStatusLine().getStatusCode(); 返回a*/ String ResponseBy=EntityUtils.toString(resp.getEntity()); //a=相应的getStatusLine().getStatusCode(); 返回responseBody.toString(); }捕获(IOE异常){ e、 printStackTrace(); } 返回null; } @凌驾 受保护的void onPostExecute(字符串结果){ //TextView aa=(TextView)findViewById(R.id.textView3); //aa.setText(结果); //按钮提交=(按钮)findViewById(R.id.btn\u iamsupport); //submit.setText(结果); Toast.makeText(MaterialSupport.this,result,Toast.LENGTH_LONG.show(); //Toast.makeText(IamSupport.this,result,Toast.LENGTH_LONG).show(); } @凌驾 受保护的void onPreExecute(){} },android,Android,这是我的代码,当运行文件时,它显示内部服务器错误。我给toast消息以检查它是否包含所有详细信息,但它显示内部服务器错误,并且我在清单中也给了用户权限 03-10 11:53:55.055 6520-6524/?E/dalvikvm﹕ heapsize setIdealFootprint开销6733824 03-10 11:53:56.116 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootpri

这是我的代码,当运行文件时,它显示内部服务器错误。我给toast消息以检查它是否包含所有详细信息,但它显示内部服务器错误,并且我在清单中也给了用户权限

03-10 11:53:55.055 6520-6524/?E/dalvikvm﹕ heapsize setIdealFootprint开销6733824 03-10 11:53:56.116 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint max1 9109504 03-10 11:53:56.116 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint max2 9109504 03-10 11:53:56.116 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint开销6733824 03-10 11:53:56.176 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint max1 9648128 03-10 11:53:56.176 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint max2 9648128 03-10 11:53:56.176 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint开销6733824 03-10 11:53:56.236 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint max1 10200064 03-10 11:53:56.236 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint max2 10200064 03-10 11:53:56.236 7795-7795/com.myapps.materialapplication E/dalvikvm﹕ heapsize setIdealFootprint开销6733824 03-10 11:54:21.771 687-689/? E/dalvikvm﹕ heapsize setIdealFootprint开销6733824


这是我的logcat错误

内部服务器错误不是客户端错误,而是来自服务器,当您有来自服务器端的请求代码500时,您将收到内部服务器错误消息。你能在日志中打印你的回复代码吗?检查应该是500。请检查您的服务器端,因为您可能遗漏了一些参数,或者某些参数值可能为空


希望这能帮助您。

您能发布logcat跟踪信息吗。@Gunaselan k当然,谢谢您的回复。如果答案有助于您解决问题,欢迎您接受。此外,我还看到了您给定代码中的糟糕编程
    public class MaterialSupportapi extends AsyncTask<String, Void, String> {
       @Override
       protected String doInBackground(String... params) {
           MaterialJson JSONOBJECT = new MaterialJson();
            name = (EditText) findViewById(R.id.edt_name);
            mobile = (EditText) findViewById(R.id.edt_contactnumber);
            street = (EditText) findViewById(R.id.edt_address1);
            city = (EditText) findViewById(R.id.edt_address2);
            state = (EditText) findViewById(R.id.edt_address3);
            zipcode = (EditText) findViewById(R.id.edt_address4);
           day=(Spinner)findViewById(R.id.spinner1_Day);
            month = (Spinner) findViewById(R.id.spinner2_month);
           time_from = (Spinner) findViewById(R.id.spinner3_time_from);
            time_to = (Spinner) findViewById(R.id.spinner4_time_to);
           JSONOBJECT.setName(name.getText().toString());
           JSONOBJECT.setMobile(mobile.getText().toString());
           JSONOBJECT.setStreet(street.getText().toString());
           JSONOBJECT.setCity(city.getText().toString());
           JSONOBJECT.setState(state.getText().toString());
           JSONOBJECT.setZipcode(zipcode.getText().toString());
           JSONOBJECT.setDay(day.getSelectedItem().toString());
           JSONOBJECT.setMonth(month.getSelectedItem().toString());
           JSONOBJECT.setTimeFrom(time_from.getSelectedItem().toString());
           JSONOBJECT.setTimeTo(time_to.getSelectedItem().toString());
           JSONObject obj = new JSONObject();
           try {
               obj.put("name",JSONOBJECT.getName());
               obj.put("mobile",JSONOBJECT.getMobile());
               obj.put("day",JSONOBJECT.getDay());
               obj.put("month",JSONOBJECT.getMonth());
               obj.put("time_from",JSONOBJECT.getTimeFrom());
               obj.put("time_to",JSONOBJECT.getTimeTo());
               obj.put("street",JSONOBJECT.getStreet());
               obj.put("city",JSONOBJECT.getCity());
               obj.put("state",JSONOBJECT.getState());
               obj.put("zipcode",JSONOBJECT.getZipcode());
               // obj.put("type",JSONOBJECT.getType());

           } catch (JSONException e) {
               e.printStackTrace();
           }
           //Toast.makeText(this, obj.toString(), Toast.LENGTH_LONG).show();
           DefaultHttpClient httpclient = new DefaultHttpClient();
           HttpPost httput = new HttpPost("https://vaananba.herokuapp.com/api/materialsupport");
           StringEntity se = null;
           try {
               se = new StringEntity(obj.toString());
           } catch (UnsupportedEncodingException e) {
               e.printStackTrace();
           }
           httput.setEntity(se);
           httput.setHeader("content-type", "application/json");
           int a = 0;
           try {
               HttpResponse resp = httpclient.execute(httput);
                /*a = resp.getStatusLine().getStatusCode();
                return a;*/
               String responseBody = EntityUtils.toString(resp.getEntity());
               //a = resp.getStatusLine().getStatusCode();
               return responseBody.toString();

           } catch (IOException e) {
               e.printStackTrace();
           }
           return null;
       }

       @Override
       protected void onPostExecute(String result) {
           //TextView aa= (TextView)findViewById(R.id.textView3);
           //aa.setText(result);
           // Button submit = (Button) findViewById(R.id.btn_iamsupport);
           //submit.setText(result);
           Toast.makeText(MaterialSupport.this, result, Toast.LENGTH_LONG).show();
           //Toast.makeText(IamSupport.this, result, Toast.LENGTH_LONG).show();
       }

       @Override
       protected void onPreExecute() {}
   }