1

私はAndroid開発の初心者で、POSTリクエストを作成して使用する必要があります。この投稿によると、 私は自分のデータを入れようとしました:

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(13);
            nameValuePairs.add(new BasicNameValuePair("SelectedCode", "25"));
            nameValuePairs.add(new BasicNameValuePair("Phone", "1234567"));
            nameValuePairs.add(new BasicNameValuePair("Text", "1234"));
            nameValuePairs.add(new BasicNameValuePair("IsTranslit", "false"));
            nameValuePairs.add(new BasicNameValuePair("IsShedule", "false"));
            nameValuePairs.add(new BasicNameValuePair("LastDate", ""));
            nameValuePairs.add(new BasicNameValuePair("LastDateHour", "00"));
            nameValuePairs.add(new BasicNameValuePair("LastDateMinuts", "00"));
            nameValuePairs.add(new BasicNameValuePair("DateSendBefore", ""));
            nameValuePairs.add(new BasicNameValuePair("DateSendBeforeHour", "00"));
            nameValuePairs.add(new BasicNameValuePair("DateSendBeforeMinuts", "00"));
            nameValuePairs.add(new BasicNameValuePair("CaptchaDeText", "h3Vcjwk2moLagspo7lnKpg%3D%3D"));
            nameValuePairs.add(new BasicNameValuePair("CaptchaInputText", "4myin2"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

しかし、うまくいきません。次に、このコードを使用しようとしました(長い行で申し訳ありません)

            httppost.setEntity(new StringEntity("SelectedCode=25&Phone=1234567&Text=123&IsTranslit=false&IsShedule=false&LastDate=&LastDateHour=00&LastDateMinuts=00&DateSendBefore=&DateSendBeforeHour=00&DateSendBeforeMinuts=00&CaptchaDeText=h3Vcjwk2moLagspo7lnKpg%3D%3D&CaptchaInputText=4myin2"));

そして、それは動作します。誰かが何が違うのか、何を間違っているのか説明できますか?

更新しました:

機能しないとは、サーバーがこの投稿リクエストを正しいものとして認識しないことを意味します。たとえば、 NameValuePair リストに間違った値を追加すると発生します。しかし、私の側からすると、最初のコードと 2 番目のコードの名前と値は同じです。不思議に思います。

4

1 に答える 1

1

vmirionov のコメントは、この問題を解決しました。トリックh3Vcjwk2moLagspo7lnKpg%3D%3Dを作ったに変更します。h3Vcjwk2moLagspo7lnKpg==

于 2013-03-20T20:15:47.853 に答える