如何在android中发送带有参数和内容类型的HttpDelete请求

时间:2016-08-16 06:59:54

标签: android android-studio http-headers apache-httpclient-4.x http-delete

我在HttpDelete Android中请求发送rest API时遇到问题。 当我点击API时显示错误。需要内容类型,我在标题中设置它,但没有找到任何我需要帮助的解决方案。 这是我尝试过的代码:

 DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
                String paramString = URLEncodedUtils.format(nameValuePairs, "utf_8");
                url += "?" + paramString;
                HttpDelete httpDelete = new HttpDelete(url);
                httpDelete.setHeader("Iauth" ,"1");
                httpDelete.setHeader("Msessid" ,sessionid);
                httpDelete.addHeader("content-type","x-www-form-urlencoded");
                Log.d("URLLLLL",url);
               // httpPost.setHeader("content-type","application/x-www-form-urlencoded;charset=UTF-8");
                HttpResponse httpResponse = defaultHttpClient.execute(httpDelete);
                HttpEntity httpEntity = httpResponse.getEntity();
                inputStream = httpEntity.getContent();

0 个答案:

没有答案