我在使用 android 中的 httpput 方法将数据发布到服务器时遇到问题。我必须向服务器发送反馈并获取 json 响应。但我收到404 错误请求。但我不知道问题出在哪里。
我在这里感到震惊,没有找到任何解决方案。有什么建议么?
我的代码如下:
HttpClient client = new DefaultHttpClient();
HttpPut put = new HttpPut(getString(R.string.feedBack));
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("userId", "8"));
pairs.add(new BasicNameValuePair("feedback",feedbackMessage
.getText().toString()));
put.addHeader("Content-Type", "application/json");
put.addHeader("Accept", "application/json");
put.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = client.execute(put);
Log.d(tag, "Result" + response.getStatusLine());