在Android中发布HTTP安全时未读取参数

时间:2011-11-07 15:02:23

标签: java android https http-post

我有一个使用https帖子到远程服务器的应用程序。

每当我尝试发布到该服务器时,我都会收到一条回复,说明我没有添加id参数。

这是我的代码

    HttpHost host = new HttpHost("hostname", 443, "https");
    HttpPost httppost = new HttpPost(uri);  
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("description", "Android"));
        nameValuePairs.add(new BasicNameValuePair("type", "Android"));
        nameValuePairs.add(new BasicNameValuePair("id", DeviceUtils.getID()));

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));           
        String content = httppost.getEntity().toString();   
    HttpResponse response = httpclient.execute(host, httppost);

我尝试过使用和不使用“自定义”httphost,但我总是得到相同的响应。 类似的代码已经在桌面上运行的javaclient中使用,它运行得很好。

Id是已经过RSA加密和Base64编码的deviceId。

关于我在这里做错了什么的想法。

0 个答案:

没有答案