【问题标题】:Android POST Data to serverAndroid POST 数据到服务器
【发布时间】:2014-11-11 23:27:25
【问题描述】:

请帮助我!我通过电子邮件将此帖子发送到服务器以进行授权,但服务器已回复

"error":"Wrong input parameters"

我知道 items 是真的!prolem 不在 items 中!

public String RegistrationByEmail(String email, String username, String password) throws IOException {
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy
                = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://speechyard.com/api/register");

    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);

        nameValuePairs.add(new BasicNameValuePair("email", email));
        nameValuePairs.add(new BasicNameValuePair("username", username));
        nameValuePairs.add(new BasicNameValuePair("pssword", password));

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = httpclient.execute(httppost);
        Id_Token_from_website2 = responseHandler(response);
        Log.v(TAG, "Id_Token_from_website :   " + Id_Token_from_website2);

    } catch (ClientProtocolException e) {
    } catch (IOException e) {
    }
    return Id_Token_from_website2;
}

【问题讨论】:

    标签: http-post androidhttpclient


    【解决方案1】:

    这里可能有错别字:

    nameValuePairs.add(new BasicNameValuePair("pssword", password));
    

    我认为应该是:

    nameValuePairs.add(new BasicNameValuePair("password", password));
    

    你忘记了 password 中的 a

    【讨论】:

    • 好吧,那我很高兴能帮上忙! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 1970-01-01
    • 2016-01-17
    • 2017-10-09
    • 2015-10-24
    • 2015-12-27
    • 1970-01-01
    相关资源
    最近更新 更多