我尝试使用以下代码向服务器发出请求:
HttpClient client = new DefaultHttpClient();
HttpPut put= new HttpPut(SERVER_URL + "/subscribe");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("UserId", params.get("UserId")));
pairs.add(new BasicNameValuePair("Endpoint", params.get("Endpoint")));
pairs.add(new BasicNameValuePair("SessionKey", params.get("SessionKey")));
pairs.add(new BasicNameValuePair("SessionSecret", params.get("SessionSecret")));
pairs.add(new BasicNameValuePair("Token", params.get("Token")));
pairs.add(new BasicNameValuePair("CultureInfo", params.get("CultureInfo")));
put.setEntity(new UrlEncodedFormEntity(pairs));
put.setHeader("Content-Type", "application/json");
HttpResponse response = client.execute(put);
response.getStatusLine();
服务器在 getStatusLine 方法中返回 500 代码响应,所以我想知道完整的请求文本以查看创建了什么请求。有什么建议可以做到吗?