1

Im new at android development and now I need to create and use POST request. According to this post I have tried to put my data:

            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));

but it doesnt work. Then I have tried to use this code (sorry for a long line)

            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"));

And it works. Can someone explain what is difference or what Im doing wrong?

UPDATED:

By doesnt work I mean that server does not recognize this post request as correct. It will happen if I add incorrect value in NameValuePair list for example. But from my side name and value in first piece of code and in the second are the same. It makes me wonder.

3
  • Doesnt work is not an error. What happens, what gets sent, what does the server receive? Commented Mar 20, 2013 at 17:43
  • 2
    If I remember well, UrlEncodedFormEntity encodes each parameter, but your h3Vcjwk2moLagspo7lnKpg%3D%3D parameter is already encoded. This could be a problem Commented Mar 20, 2013 at 17:46
  • hmm, yes, you was right Commented Mar 20, 2013 at 20:07

1 Answer 1

1

vmirionov's comment solved this issue. Changing h3Vcjwk2moLagspo7lnKpg%3D%3D to h3Vcjwk2moLagspo7lnKpg== made a trick.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.